.net - Trying to add functionality to MvcHandler -


I am currently trying to add 301 redirects to my routes in MVC

doing this for I have tried to inherit from MvcHandler the handler tilts with the right values, but I am not able to debug Adityagit methods

can someone make me do this work? asp.net pipe just find their own thing ...

  public class CodeHttpHandler: MvcHandler {public CodeHttpHandler (RequestContext p_requestContext): base (p_requestContext) {} protected override void ProcessRequest (HttpContext p_httpContext) {} protected override void ProcessRequest (HttpContextBase p_httpContext) {}}  

update:

the solution I've found so far:

  Public Code CodeRouteHandler: IRouteHandler {Public System.Web.IHttpHandler GetHttpHandler (requestContext requestContext) {Return New CodeHandler (requestContext); }} Public class CodeRouteConstants {public const string code = "code"; Public const string REDIRECT = "redirection"; } Public class CodeHandler: MvcHandler {Public CodeHandler (RequestContext requestContext): Base (requestContext) {} Private int? Handle-coded root (system .http: HTTP://ttextbase.htquenttext) {var context = http contex. request. Request Number If (context.DataTokens.ContainsKey (CodeRouteConstants.CODE)) {var statusCode = Int32.Parse (context.DataTokens [CodeRouteConstants.CODE] as string ?? "500"); HttpContext.Response.StatusCode = statusCode; If (context.DataTokens.ContainsKey (CodeRouteConstants.REDIRECT)) {var redirectionMap = context.DataTokens [CodeRouteConstants.REDIRECT] as string ?? "404"; Foreach (var v in context.Values) {redirectionMap = redirectionMap.Replace (string.Format ("{{{{{0}}}, v.Key), v.value as string);} HttpContext Response.AddHeader ( "location", redirection map);} HttpContext.Response.End (); return status code;} return null;} protected override System.IAsyncResult BeginProcessRequest (System.Web.HttpContext HttpContext, System.AsyncCallback callback object state) {var statusCode = HandleCodedRoute (new HttpContextWrapper (HttpContext)); if (statusCode.HasValue) {return null;} return Adharkbinprkriya Rikwaist (Acpiconteks, callback, state);} protected override Sistmkaisa NCRSAT Start ProcessSecurity (System WebHttpTinTexBaseHPConnectx, System.Ansink Callback Callback, Object State) {Return Base.BEGIN PROCURED Security (HPContax, Callback, State);} Safe Override Zero Process Measure (System.Web.HttpContext httpContext) {base.ProcessRequest (HttpContext);} Secure Override Zero Process Requests (System Web. HTTPTextBase HP Contex) {base.ProcessRequest (httpContext); }}  

Hey, I also just ran into this problem in process vacancy () My breakpoints were never hit. I do not have a full-proof resolution for your problem, but I have a job - around which you want what you want. Try to override the BeginProcessRequest () method from MvcHandler instead of ProcessRequest In the context, the path (action and controller) should be in the information, if you are searching for it.


Comments