How to change Session for only one route in asp.net mvc?


How to change Session for only one route in asp.net mvc?



How to handle Application_BeginRequest using a custom filter in asp.net mvc?

I want to restore session only for one route (~/my-url).

It would be cool, if I could create a custom filter and handle that.

protected void Application_BeginRequest(object sender, EventArgs e)     {         var context = HttpContext.Current;          if (string.Equals("~/my-url",             context.Request.AppRelativeCurrentExecutionFilePath,              StringComparison.OrdinalIgnoreCase))         {             string sessionId = context.Request.Form["sessionId"];              if (sessionId != null)             {                 HttpCookie cookie = context.Request.Cookies.Get("ASP.NET_SessionId");                 if (cookie == null)                 {                     cookie = new HttpCookie("ASP.NET_SessionId");                 }                 cookie.Value = sessionId;                 context.Request.Cookies.Set(cookie);             }         } 

ASP.NET MVC - HTML.BeginForm and SSL

1:

asp.net mvc IDataErrorInfo validation when using ViewModel
I did it using IRouteHandler.. How to make data available when one Controller's View calls another Controller's View?
public class SessionHandler : IRouteHandler {     public System.Web.IHttpHandler GetHttpHandler(RequestContext requestContext)     {         string sessionId = requestContext.HttpContext.Request.Form["sessionId"];          if (sessionId != null)         {             HttpCookie cookie = requestContext.HttpContext.Request.Cookies.Get("ASP.NET_SessionId");             if (cookie == null)             {                 cookie = new HttpCookie("ASP.NET_SessionId");             }             cookie.Value = sessionId;             requestContext.HttpContext.Request.Cookies.Set(cookie);         }           return new MvcHandler(requestContext);     } } 
This is in global.asax (abc/qwr is the route):. Is WPF and MVC same concepts?
RouteTable.Routes.Add(new Route(                 "abc/qwr",                 new RouteValueDictionary(new {controller = "MyController", action = "MyAction"}),                 new RouteValueDictionary(),                 new RouteValueDictionary(new { Namespaces = new[] { typeof(MyControllerController).Namespace } }),                 new SessionHandler()         )); 
Any comments?. jQUERY onclick post
What is the best way to store WMD input/markdown in SQL server and display later?

88 out of 100 based on 43 user ratings 398 reviews

@