Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I am really sorry the issue was due to a mistake by one of my colleague where he created an Area and for the area registration he has mentioned the routing rule incorrectly.</p> <pre><code> public class SharedAreaRegistration : AreaRegistration { public override string AreaName { get { return "Shared"; } } public override void RegisterArea(AreaRegistrationContext context) { context.MapRoute( "Shared_default", "{controller}/{action}/{id}", //&lt;---- This made the issue with routing new { action = "Index", id = UrlParameter.Optional } ); } } </code></pre> <p>How i figured out the mistake ill explain the steps below so that it would be helpful.</p> <p>First i installed the <a href="http://nuget.org/packages/routedebugger" rel="nofollow noreferrer">Route Debugger</a> </p> <p>Then Wrote the Application_Error in the Global.asx to handle the error. if this is not written the Route Debugger will not be able to find the routing.</p> <pre><code>protected void Application_Error(object sender, EventArgs e) { Exception exception = Server.GetLastError(); // Log the exception. //ILogger logger = Container.Resolve&lt;ILogger&gt;(); // logger.Error(exception); Response.Clear(); HttpException httpException = exception as HttpException; RouteData routeData = new RouteData(); routeData.Values.Add("controller", "Error"); if (httpException == null) { routeData.Values.Add("action", "Index"); } else //It's an Http Exception, Let's handle it. { switch (httpException.GetHttpCode()) { case 404: // Page not found. routeData.Values.Add("action", "HttpError404"); break; case 500: // Server error. routeData.Values.Add("action", "HttpError500"); break; // Here you can handle Views to other error codes. // I choose a General error template default: routeData.Values.Add("action", "General"); break; } } // Pass exception details to the target error View. routeData.Values.Add("error", exception); // Clear the error on server. Server.ClearError(); // Avoid IIS7 getting in the middle Response.TrySkipIisCustomErrors = true; // Call target Controller and pass the routeData. //IController errorController = new ErrorController(); //errorController.Execute(new RequestContext( // new HttpContextWrapper(Context), routeData)); } </code></pre> <p>Then i typed the URL hxxp://localhost:63363/Commercial/VesselManagement and the output was <img src="https://i.stack.imgur.com/keGRY.jpg" alt="enter image description here"></p> <p>In the output route data and data token clearly says it tries to find the commercial controller and VesselManagement ACtion inside Shared area. </p> <p>Reason for the error is Shared Area routing incorrectly specified and when that is corrected by addeing Share in frount it ws resolved. </p> <p>public override void RegisterArea(AreaRegistrationContext context) { context.MapRoute( "Shared_default", "Shared/{controller}/{action}/{id}", new { action = "Index", id = UrlParameter.Optional } ); }</p> <p>Thanks to RouteDebugger</p> <p><strong>NOTE:</strong> Routing works top to bottom and the moment it finds a matching route it will ignore the rest. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload