logo
down
shadow

RouteConfig triggers 500 error when refreshing page


RouteConfig triggers 500 error when refreshing page

By : Anne-Marie Reppon
Date : November 20 2020, 01:01 AM
I think the issue was by ths following , The issue is related to improperly set server side. Firstly try to turn off the html5 mode
code :
//$locationProvider.html5Mode(true);
$locationProvider.html5Mode({enabled: false});
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("fonts*.woff");
routes.IgnoreRoute("*.js");
routes.IgnoreRoute("*.html");
routes.IgnoreRoute("*.css");
routes.IgnoreRoute("api/*");

routes.MapRoute(
    name: "Default",
    url: "{dummyController}/{dummyAction}/{dummy1}/{dummy2}/{dummy3}",
    defaults: new { controller = "Home", action = "Index"
        , dummyController = UrlParameter.Optional
        , dummyAction = UrlParameter.Optional
        , dummy1 = UrlParameter.Optional
        , dummy2 = UrlParameter.Optional
        , dummy3 = UrlParameter.Optional
    }
);
public static void RegisterRoutes(RouteCollection routes)
{
    routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
    routes.IgnoreRoute("fonts*.woff");
    routes.IgnoreRoute("*.js");
    routes.IgnoreRoute("*.html");
    routes.IgnoreRoute("*.css");
    routes.IgnoreRoute("api/*");

    // keep this application special settings
    routes.MapRoute("templates", "templates/{action}.html",
     new { controller = "Home", action = "Templates", name = "" }
    );
    routes.MapRoute("contacts","contacts",
       new { controller = "Home", action = "Contacts", id = UrlParameter.Optional }
    );

    // this should do the job on F5
    routes.MapRoute(
        name: "Default",
        url: "{dummyController}/{dummyAction}/{dummy1}/{dummy2}/{dummy3}",
        defaults: new { controller = "Home", action = "Index"
            , dummyController = UrlParameter.Optional
            , dummyAction = UrlParameter.Optional
            , dummy1 = UrlParameter.Optional
            , dummy2 = UrlParameter.Optional
            , dummy3 = UrlParameter.Optional
        }

);


Share : facebook icon twitter icon
How to set the default page and URL in RouteConfig file

How to set the default page and URL in RouteConfig file


By : Jacob
Date : March 29 2020, 07:55 AM
Hope that helps This is my first time developing in MVC and have been stuck with this problem for a while now. , Change your routes to
code :
routes.MapRoute(
  name: "Project",
  url: "Project/{action}/{projectId}",
  defaults: new { controller = "Project", action = "Index", projectId = UrlParameter.Optional }
);

routes.MapRoute(
  name: "Default",
  url: "{controller}/{action}/{id}",
  defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
How to use RouteConfig to append a page URL

How to use RouteConfig to append a page URL


By : odin tung
Date : March 29 2020, 07:55 AM
Any of those help You can't do this purely with routing because the browser will always send form values as query string parameters when they are part of a GET request. Once the request has been sent to the server, the MVC framework can't do anything about the URL that was used.
This leaves you with only one real option (assuming you don't want to send a custom request using JavaScript), which is to explicitly redirect to the desired URL (meaning you will always have two requests when this form is submitted).
code :
public class FormController : Controller
{
    public ActionResult Index(string MyType)
    {
        return RedirectToAction("Index", "MyProperController", new { MyType });
    }
}
routeconfig.cs - page doesnot exist

routeconfig.cs - page doesnot exist


By : wackio
Date : March 29 2020, 07:55 AM
it fixes the issue Your route patterns for both AllQuotesByKeywordwithoutKeywordID and AllQuotesByKeywordWithKeywordID are the same as those for AuthorNameonly and AuthorNamewithAuthorID, respectively. The fact that you're naming the route parameters differently is not enough to distinguish the routes from each other. As a result, the first one that matches wins, which in this case is AuthorNameonly and AuthorNamewithAuthorID. In other words, when you hit a route like /Keyword/Love, Keyword goes into controller, giving you the correct controller, but, Love is put into an author param, which your action on KeywordController will not be able to utilize, because it's looking for a key param. Further, since you're not specifying the action, the default action is being utilized, which for this route is AllQuotesByAuthorWithoutAuthorID, which is not even an action on KeywordController, hence your 404.
Long and short, you need something else to distinguish these routes from each other. You could potentially just change the routes to:
code :
routes.MapRoute(
    name: "AuthorNameonly",
    url: "author/{author}",
    defaults: new { controller = "Author", action = "AllQuotesByAuthorWithoutAuthorID" });

routes.MapRoute(
    name: "AuthorNamewithAuthorID",
    url: "author/{author}/{id}",
    defaults: new { controller = "Author", action = "AllQuotesByAuthorWithAuthorID"});
routes.MapRoute(
    name: "AllQuotesByKeywordwithoutKeywordID",
    url: "keyword/{key}",
    defaults: new { controller = "Keyword", action = "AllQuotesByKeywordwithoutKeywordID" });

routes.MapRoute(
    name: "AllQuotesByKeywordWithKeywordID",
    url: "keyword/{key}/{id}",
    defaults: new { controller = "Keyword", action = "AllQuotesByKeywordWithKeywordID" });
When clicking The modal ok button, it triggers clicks by the number of using modal without refreshing the page

When clicking The modal ok button, it triggers clicks by the number of using modal without refreshing the page


By : Vadim Shubkin
Date : March 29 2020, 07:55 AM
this one helps. Usually this happens when the click handler is called multiple times on an element through calling a function. Perhaps try unbinding and rebinding the event, like so
code :
$("#change").off('click').on('click');
Error on index page load. Issue with RouteConfig.cs

Error on index page load. Issue with RouteConfig.cs


By : apoorva bhavsar
Date : March 29 2020, 07:55 AM
will be helpful for those in need You should not access /Home/Index.cshml but /Home/Index.
Visual Studio has a behavior that if you hit F5 to launch the app while being inside a razor view, it'll open that razor view in the browser.
Related Posts Related Posts :
  • How to hard code a select list from a value?
  • Passing parameter to telerik popup
  • ASP.NET Web API with x509 security certificate
  • ASP.NET get cell from DataRow in a datatable?
  • how can I use a Microsoft Account to authenticate to my website
  • Unable to start debugging on the web server. Unable to connect to the webserver
  • Not able to connect to cube
  • PDF creation using itextsharp is not working in client's server
  • Date field does not display the value in Chrome browser
  • Get Text of Hyperlink which is sitting inside template field in a gridview
  • how to scale image in email body?
  • FormAuthentication not working
  • Using Entity Framework constructors in derived classes
  • Code first database not being created from model
  • Loading external DLL into WinDBG
  • Pass JSON data to strongly typed partial view in ASP.NET
  • ASP.NET MVC 4 Application w/ Areas apps suffering horrible render times
  • view sections cause problems if not rendered in layout
  • Modifying code in a website on IIS
  • Autofac and WebAPI - Default constructor error
  • Is it possible to change the query string value
  • MetroUI buttoon server side Click Event
  • Change default idseparator in .Net 3.5?
  • Placing DataBound Drop Down List into TableCell
  • MVC 5 AspNet Identity - Value cannot be null. Parameter name: source
  • Save the value of Dynamically created textbox
  • asp.net identity membership saving both email and username for a user
  • IIS Manager Error
  • Grid dont have data Kendo UI and AngularJS in ASP.NET MVC
  • Project stops working after installing signalr
  • While querying with linq , Max function retrieves upto '9' if more than 9 values in the list
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org