0

OK so I would love to know how to check witch routes are currently in place in my MVC app, because currently I have this setup for MVC3 app and as far as I know everything is correct, but the "Data" route still does not work:

global.asax

using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using System.Web.Routing; using InteractiveAnalysis.Common; using System.Data.SqlClient; using System.Data; using System.Configuration; using System.Diagnostics; using InteractiveAnalysis.App_Start; using System.Web.Optimization; namespace InteractiveAnalysis { // Note: For instructions on enabling IIS6 or IIS7 classic mode, // visit http://go.microsoft.com/?LinkId=9394801 public class MvcApplication : ToolsFramework.Mvc.ToolsFrameworkHttpApplicationBase { public static void RegisterGlobalFilters(GlobalFilterCollection filters) { filters.Add(new HandleErrorAttribute()); } public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( "Excel", // Route name "excel", // URL with parameters new { controller = "Excel", action = "Index"} // Parameter defaults ); routes.MapRoute( "Data", // Route name "data", // URL with parameters new { controller = "Data", action = "Index" } // Parameter defaults ); routes.MapRoute( "Version", // Route name "version/{action}", // URL with parameters new { controller = "Version", action = "Index" } // Parameter defaults ); routes.MapRoute( "Main", // Route name "{ver}", // URL with parameters new { controller = "Main", action = "Index", ver = UrlParameter.Optional } // Parameter defaults ); /* routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.IgnoreRoute("cache/{action}/{id}"); routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Main", action = "Index", id = UrlParameter.Optional } // Parameter defaults ); */ } protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RegisterGlobalFilters(GlobalFilters.Filters); RegisterRoutes(RouteTable.Routes); UnityObject.Register(); ToolsFramework.Cache.OutputCacheHandeler.addCacheKey(UnityObject.APPLICATION_NAME); //OldBundleConfig.RegisterBundles(BundleTable.Bundles); } protected void Application_Error(object sender, EventArgs e) { Response.Clear(); Exception exception = Server.GetLastError(); HttpException httpException = (exception.GetBaseException() as HttpException); if (httpException != null) { switch (httpException.GetHttpCode()) { case 501: //function not implemented Server.ClearError(); Response.Write(exception.Message); return; } } #if !DEBUG if (Euroland.Azure.Utilities.AzureEnvironment.IsAvailable) { EventLog.WriteEntry(InteractiveAnalysis.Common.UnityObject.APPLICATION_NAME, "Error:\r\n\r\n" + exception.Message + "\r\n\r\nStack Trace:\r\n" + exception.StackTrace, EventLogEntryType.Error); } else { Exception exx = Server.GetLastError().GetBaseException(); System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace(exx, true); string Category = "ASP.NET error"; string ASPCode = "N/A"; string ASPDescription = exx.ToString(); if (ASPDescription.Length > 500) { ASPDescription = ASPDescription.Substring(0, 500); } string Column = trace.GetFrame(0).GetFileColumnNumber().ToString(); string Description = exx.Message.ToString(); if (Description.Length > 500) { Description = Description.Substring(0, 500); } string File = trace.GetFrame(0).GetFileName(); string Line = trace.GetFrame(0).GetFileLineNumber().ToString(); string Number = "N/A"; string Source = trace.GetFrame(0).GetMethod().Name; if (Source.Length > 500) { Source = Source.Substring(0, 250); } string ServerName = HttpContext.Current.Server.MachineName; //Request.ServerVariables["SERVER_NAME"]; string ServerIP = Request.ServerVariables["LOCAL_ADDR"]; string RemoteIP = Request.ServerVariables["REMOTE_ADDR"]; string UserAgent = Request.ServerVariables["HTTP_USER_AGENT"]; string Referer = Request.ServerVariables["REFERER"]; string URL = Request.Url.ToString(); //currently it can function in the local enviroment SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["LocaleErrorConnectionString"].ToString()); SqlCommand myCommand = new SqlCommand(); myCommand.CommandType = CommandType.StoredProcedure; myCommand.CommandText = "spInsertServerError"; myCommand.Connection = conn; myCommand.Parameters.AddWithValue("@Category", Category); myCommand.Parameters.AddWithValue("@ASPCode", ASPCode); myCommand.Parameters.AddWithValue("@ASPDescription", ASPDescription); myCommand.Parameters.AddWithValue("@Column", Column); myCommand.Parameters.AddWithValue("@Description", Description); myCommand.Parameters.AddWithValue("@File", File); myCommand.Parameters.AddWithValue("@Line", Line); myCommand.Parameters.AddWithValue("@Number", Number); myCommand.Parameters.AddWithValue("@Source", Source); myCommand.Parameters.AddWithValue("@ServerName", ServerName); myCommand.Parameters.AddWithValue("@ServerIP", ServerIP); myCommand.Parameters.AddWithValue("@RemoteIP", RemoteIP); myCommand.Parameters.AddWithValue("@UserAgent", UserAgent); myCommand.Parameters.AddWithValue("@Referer", Referer); myCommand.Parameters.AddWithValue("@URL", URL); try { conn.Open(); myCommand.ExecuteNonQuery(); } catch { } finally { if (conn.State != ConnectionState.Closed) { conn.Close(); } //Server.ClearError(); } } #endif } } } 

DataController.cs

using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using System.Text; using System.Globalization; using InteractiveAnalysis.Models; using ToolsFramework; namespace InteractiveAnalysis.Controllers { public class DataController : Controller { // // GET: /Data/ public string Index() { return "something"; } } } 

But every time I check "localhost:62570/data/" I get a 404 and I just do not get it. What am I missing why hasn't the "Data" route taken hold? As far as I know I have done everything correctly.

1 Answer 1

1

The best and easiest way to check/debug routes is using the Phil Haack's route debugger, you can install it with following nuget package

Sign up to request clarification or add additional context in comments.

1 Comment

Cheers for this, although the for some reason the code I got from NuGuget was missing the RouteDebugger class, but nice to know that something like this exists next time I need it I will simply compile my own version from the source

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.