You must Sign In to post a response.
  • Category: ASP.Net MVC

    How to Handels for Wrong Controller Name or Action Method Name

    Hello ,

    In ASP.NET Web site , I have newly implemented MVC, some part is MVC some ASP.NET .

    I have static site which hosted on same domain, with URL Rewriting.

    So any request comes from static site like OR

    it gives server error which handled in Application_Error method

    My Actual Controller and Action Method is like this.


    name: "Default",
    url: "{controller}/{action}/{id}",
    defaults: new { controller = "Controller", action = "IndexActionMethod", id = UrlParameter.Optional }

    What I understand that "/abc/career/" OR "/abc/aboutUs/" when these request comes , tries to Map "abc" as controller and "career" OR "aboutUs" as Action method which does not exists.

    so how can I Ignore these request that these should not treated as MVC Controller/Action Request.

    one more thing this working fine only I am getting no implementation Error in Logger. I want to handle that error.

    Regards ,
    Jeevan Joshi
  • #769719
    I think if you handle error handling in GLOBAL file as below In your application you can override the "Application_Error" event and do a response.redirect from the global error event. So if the error handling is not done at the controller level it will get propagated to "Global.asax" file

    public class MvcApplication : System.Web.HttpApplication
    protected void Application_Error(object sender, EventArgs e)
    Exception exception = Server.GetLastError();

    Hope this handles wrong controller name during request processing to web server.

    B.Ramana Reddy

  • Sign In to post your comments