Custom Route Handler Sample
public class CustomRouteHandler : MvcRouteHandler
{
protected override IHttpHandler GetHttpHandler(RequestContext requestContext)
{
var acceptValue = requestContext.HttpContext.Request.Headers["Accept"];
if (true /* do something with the accept value */)
{
// Set the new route value in the
// requestContext.RouteData.Values dictionary
// e.g. requestContext.RouteData.Values["action"] = "Customer";
SetPermission(requestContext, requestContext.RouteData.Values["controller"].ToString(), requestContext.RouteData.Values["action"].ToString());
}
// return new CustomHttpHandler();
return base.GetHttpHandler(requestContext);
}
private void SetPermission(RequestContext requestContext, string controller, string action)
{
VIPEREntities db = new VIPEREntities();
var permission = db.sp_GetAccessPermission(controller, action, "fbe5b60f-dfff-4384-808d-d212e4791c00");
}
}
public class CustomHttpHandler : MvcHttpHandler // IHttpHandler
{
public bool IsReusable
{
get
{ return false;
}
}
public void ProcessRequest(HttpContext context)
{
context.Session["SessionPermission"] = "2";
base.ProcessRequest(context);
//context.Response.Redirect("http://www.itfunda.com", true);
}
}
No comments:
Post a Comment