0

My query is exactly the same as Rewrite AngularJS URL , but I am using IIS as my web server.

How do I fix the URL? Currently my URL looks like

http://example.com/app#/ 

which needs to be changed like

http://example.com/app/#/
Community
  • 1
  • 1
Karthik
  • 1,064
  • 2
  • 16
  • 33

1 Answers1

0

In case we are using ASP.NET MVC runtime to trigger Index action on the HomeController to act as "index.html" (returning the view index.cshtml) - we can just add these lines into it:

public ActionResult Index()
{
    var root = VirtualPathUtility.ToAbsolute("~/");
    var applicationPath = Request.ApplicationPath;
    var path = Request.Path;

    var hasTraillingSlash = 
          root.Equals(applicationPath, StringComparison.InvariantCultureIgnoreCase)
       || !applicationPath.Equals(path, StringComparison.InvariantCultureIgnoreCase);

    if (!hasTraillingSlash)
    {
        return Redirect(root + "#");
    }

    return View();
}

Check this Browser address will not be displayed correctly in ui-route

Community
  • 1
  • 1
Radim Köhler
  • 122,561
  • 47
  • 239
  • 335