iroutehandler

How to redirect user to another Url from MVC Custom Router Handler?

孤者浪人 提交于 2019-12-12 11:33:39
问题 I am working with CustomMvcRouterHandler, Based on some logic I just want to redirect user to another Url from CustomHandler. public class CustomMvcRouterHandler : IRouteHandler { public IHttpHandler GetHttpHandler(RequestContext requestContext) { if (requestContext.HttpContext.Request.IsAuthenticated) { if (logic is true) { string OrginalUrl = "/Home/AboutUs"; // redirect Url = "/Home/CompanyProfile"; return new MvcHandler(requestContext); } } return new MvcHandler(requestContext); } } How

Custom IRouteHandler route screws up MVC link building

醉酒当歌 提交于 2019-12-08 03:49:08
问题 I have a custom routehandler in ASP.NET MVC2 to catch all url's at a prefixed path like this: routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.Add(new Route("@api/{*all}", new ApiHandler())); routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults ); Routing works fine, but if i use Html.Actionlink or return ReturnToAction() from a controller, the uri

IRouteHandler in Web Forms: Routing requests that require HttpContext.User

时间秒杀一切 提交于 2019-12-08 01:28:22
问题 I'm trying to add a pretty basic route to an Asp.Net Web Forms app (running under IIS 7, integrated mode): for requests coming to http://mydomain.com/foo/ I would like to show the results of a dynamic page (http://mydomain.com/foopage.aspx). I've created a RouteHandler that does all this and it seems to be routing correctly. public IHttpHandler GetHttpHandler(RequestContext requestContext) { var page = System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath("~/foo.aspx", typeof

Custom IRouteHandler route screws up MVC link building

佐手、 提交于 2019-12-06 15:53:04
I have a custom routehandler in ASP.NET MVC2 to catch all url's at a prefixed path like this: routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.Add(new Route("@api/{*all}", new ApiHandler())); routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults ); Routing works fine, but if i use Html.Actionlink or return ReturnToAction() from a controller, the uri built creates a broken uri like this: /@api?action=Add&controller=Home instead of /Home/Add How can i

Session is null in IRouteHandler.GetHttpHandler with Asp.net routing

扶醉桌前 提交于 2019-12-04 01:32:57
问题 I'm trying to get Session enabled in the GettHttpHandler method of my IRouteHandler classes but session is always null. Could someone tell me what I'm doing wrong? In global.asax I have RouteTable.Routes.Add("All", new Route("{*page}", new MyRouteHandler())); The MyRouteHandler class where Session is null looks like this: public class MyRouteHandler : IRouteHandler, IRequiresSessionState { public System.Web.IHttpHandler GetHttpHandler(RequestContext requestContext) { string test = HttpContext

Session is null in IRouteHandler.GetHttpHandler with Asp.net routing

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-01 05:29:16
I'm trying to get Session enabled in the GettHttpHandler method of my IRouteHandler classes but session is always null. Could someone tell me what I'm doing wrong? In global.asax I have RouteTable.Routes.Add("All", new Route("{*page}", new MyRouteHandler())); The MyRouteHandler class where Session is null looks like this: public class MyRouteHandler : IRouteHandler, IRequiresSessionState { public System.Web.IHttpHandler GetHttpHandler(RequestContext requestContext) { string test = HttpContext.Current.Session["test"].ToString(); return BuildManager.CreateInstanceFromVirtualPath("~/Page.aspx",