This repository was archived by the owner on Jun 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Controllers responses
Alexanderius edited this page Sep 14, 2016
·
3 revisions
All default controllers responses can be found in Simplify.Web.Responses
namespace.
Loads specified template and puts it to the data collector (template data will be added to the MainContent
variable of the DataCollector
).
- StaticTpl(string templateFileName) - just loads and puts template data to the
DataCollector
.
public override ControllerResponse Invoke()
{
return new StaticTpl("Default");
}
- StaticTpl(string templateFileName, string title) - the same as above, but also adds a site title into the
Title
variable ofDataCollector
.
public override ControllerResponse Invoke()
{
return new StaticTpl("MyPageTemplate", StringTable.MyPageTitle);
}
Puts a string into the MainContent
variable of the DataCollector
.
public override ControllerResponse Invoke()
{
return new Tpl("Some text");
}
public override ControllerResponse Invoke()
{
return new Tpl("Some text", StringTable.MyPageTitle);
}
public override ControllerResponse Invoke()
{
return new Tpl(TemplateFactory.Load("MyPageTemplate").Get(), StringTable.MyPageTitle);
}
Sends a string to a client and HTML page will not be generated.
public override ControllerResponse Invoke()
{
return new Ajax("Some string");
}
The same as Tpl
, but at first parameter you can specify exact DataCollector
variable name.
public override ControllerResponse Invoke()
{
return new InlineTpl("LoginControl", TemplateFactory.Load("LoginControlTemplate").Get());
}
Redirects the client to an URL or by specifying a redirection type.
public override ControllerResponse Invoke()
{
return new Redirect("http://somelink.com");
}
public override ControllerResponse Invoke()
{
return new Redirect(RedirectionType.PreviousPage);
}
Sends a file to the client
public override ControllerResponse Invoke()
{
return new File("MyFile.txt", "text/plain", Encoding.UTF8.GetBytes("My file content"));
}
Serializes a view model and puts it into a template, then that template will be put into the MainContent
variable of the DataCollector
.
public class LoginViewModel
{
[Required]
public string UserName { get; set; }
[Required]
public string Password { get; set; }
public bool RememberMe { get; set; }
}
public override ControllerResponse Invoke()
{
var model = new LoginViewModel {UserName = "Foo"};
return new ViewModel<LoginViewModel>("LoginPage", model);
}
- Getting Started
- Main Simplify.Web principles
- Simplify.Web controllers
- Simplify.Web views
- Simplify.Web templates
- Simplify.Web configuration
- Templates variables
- Static content
- Template factory
- Data collector
- String table
- File reader
- Web context
- Environment
- Language manager
- Redirector
- HTML