0

i have enabled the html5mode to remove Hashing from web url,after that i get an error.so i have mentioned the base href in master page. set rewrite url in web config.

when i goes into state view page and refresh the page it will show the wrong url.when launch the application in iis 7.5 getting error.

for that i have rewrite the url.

enter image description here

<rewrite>
<rules>
<rule name="RewriteRules stopProcessing="true">
<match url=".*"/>
<conditions logicalGrouping="MatchAll">
<add input ="{REQUEST_FILEName}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILEName}" matchType="IsDirectory"  negate="true"/>
<add input ="{REQUEST_URI}" pattern="^/(api)" negate="true"/>
</conditions>
<action type="Rewrite" url="home/home"/>
</rule>
</rules>
</rewrite>
</system.webServer>

Can anyone helpme

1

1 Answer 1

1

when you enable html5mode, your all request should redirected to your main url (where your application start ex. home/index). try add below code in the RegisterRoutes method

public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            routes.MapRoute(
                  name: "Default1",
                  url: "{*.}",
                  defaults: new
                  {
                      controller = "Home",
                      action = "Index",
                  }
              );
            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );
        }
Sign up to request clarification or add additional context in comments.

1 Comment

so i have don't need to rewrite the url in webconfig and base href in layout ? mentioned the route config in enough.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.