Add script aliases and paths to some cshmlts you like to be able to call in the "renderscript" template:
aliases.Add("demo","~/macroscripts/demo.cshtml");
... which it makes it calleable with www.mysite.com/renderscript?a=demo
For easy adding Ajax with the help of Razor scripts.
You can for example make a script that returns json:
@{
var x = new {foo="whatever"};
Json.Write (x, Response.Output);
}
And you can make a script that handles postdata, for example:
@{
var returnValue="";
if (IsPost)
{
name = Request["name"];
// do something useful...
returnValue = "Thank you " + name + "!";
}
@returnValue
}
// The source for this is simply a template with the following content:
<%@ Master Language="C#" MasterPageFile="~/umbraco/masterpages/default.master" AutoEventWireup="true" %>
<asp:Content ContentPlaceHolderID="ContentPlaceHolderDefault" runat="server"><umbraco:macro runat="server" language="razor">
@{
var aliases = new Dictionary<string, string>();
// add your script aliases here
aliases.Add("demo","~/macroscripts/demo.cshtml");
// makes them calleable with www.mysite.com/renderscript?a=demo
var alias = Request["a"];
if (alias != null)
{
if (aliases.ContainsKey(alias))
{
@RenderPage(aliases[alias])
}
}
}
</umbraco:macro></asp:Content>