Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Remove "#" from URL routing #2397


User avatar
0
pnw created

According to [https://www.codeproject.com/tips/826753/removing-sharp-from-url-in-angularjs]), we can get rid of the # from our routes.

I need this to happen because my corporate authentication system removes everything after a # so the call back to my site can't deep link.

The tip on codeproject doesn't seem to work with Abp. I'm using Abp 1.0.0.0. What is your way to make this happen?


3 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Can you check suggested articles here #330@32d1090d-2196-40d3-8598-09314155f96c.

  • User Avatar
    0
    pnw created

    What I ended up doing is to add a new ASPNET controller (I just added it to the existing HomeController) that takes a non # url and rewrites it and then calls the Angular url.

    For example, in Angular I have routes that look like #/page1/10 #/page2/3 etc

    My new ASPNET controller can take routes that look like /home/page/1/10 /home/page/2/3

    Those routes call this controller

    public ActionResult page()
    {
        return Redirect(Request.Url.OriginalString.Replace("home", "#").Replace("page/", "page"));
    }
    

    It does the trick because I have only a specialized need for non-# urls in embedded email links. Users don't have to know or use these urls directly. And I don't have to have a raft of custom ASPNET controllers to make it happen since my Angular view names follow a strict pattern.

    Note: I also added the non-# route structure to RouteConfig.cs

  • User Avatar
    0
    ismcagdas created
    Support Team

    Thanks @pnw,

    This is very helpful.