Vulnerability in EPiServer.Forms
I have configured a partial route in a website which is using web form templates.
I have followed the tutorial on partial routing and am able to register a partial route which correctly loads my aspx template when the route is matched.
I dont know the best way to access the custom route data from within the web form template.
Following the example in the SDK, if I where to create a webforms template to display a "NewsContent" item, the code behind I would look like this.
public partial class NewsContentTemplate : EPiServer.SimplePage, IRenderTemplate<NewsContent>
protected void Page_Load(object sender, EventArgs e)
// This is how i am getting the route data
var data = ((NewsContent)Request.RequestContext.RouteData.DataTokens["routedData"]);
The code for accessing the route data works but is this correct / the best way? If this was a page, I would inherit TemplatePage<T> which gives typed access to the model, however I cannot do that here as NewsContent is not a page in the CMS.
You should be able to get the routed data through extension method to RequestContext that resides in namespace EPiServer.Web.Routing:
var newsContent = Request.RequestContext.GetRoutedData<NewsContent>();
Thanks Johan, thats what I was looking for!