skip to Main Content

It should not return the URL like http://something.azurewebsites.net/signup instead custom domain name space.

with JavaScript and C# as well.

able to see using developer options of the browser or using fiddler.

something like

HttpContext.Current.Request.Url.Scheme+"://"+HttpContext.Current.Request.Url.Host+"/SignUp/"

2

Answers


  1. Using custom domain name getting current path name.

    1. System.IO.Path.GetFullPath method to get the full path of the current executing assembly.

    2. System.Reflection.Assembly.GetExecutingAssembly().Location -To get the location of the current executing assembly.

    3. And combining the custom domain and the current path to get the complete path.

    To fetch the path name for the domain space names with JavaScript you can use

    window.location.hostname

    'window.location.hostname` if you dont want the `port` (like `http://localhost:8080/`, `window.location.host = 'localhost:8080'` and `window.location.hostname = 'localhost`
    
    string str = HttpContext.Current.Request.Url.PathAndQuery;
    string strUrl = HttpContext.Current.Request.Url.AbsoluteUri.Replace(str, "/");
    
    string customDomain = "https://www.something.com/";
    
    string currentPath = System.IO.Path.GetFullPath(System.Reflection.Assembly.GetExecutingAssembly().Location);
    string combinedPath = customDomain + currentPath;
    
    Console.WriteLine("The combined pah is: " + combinedPath);
    

    Reference taken from
    MDN Web Docs

    Login or Signup to reply.
  2. It seems like you are having issue with the URL being returned from your Azure Web App. The URL is returning the Azure Web App URL instead of the custom domain name.

    To get the current path name using C#, you can use the HttpContext.Current.Request.Url property to get the URL of the current request.

    You can then use the Scheme, Host, and Path properties to construct the URL you want.

    string url = HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Host + "/SignUp/";
    

    In JavaScript, you can use the window.location object to get the URL of the current page. You can then use the protocol, host, and pathname properties to construct the URL you want.

    var url = window.location.protocol + "//" + window.location.host + "/SignUp/";
    

    You may also try using Azure Front Door to route traffic to your Azure Web App. Azure Front Door allows you to configure custom domains and URL paths, which can help you achieve the desired URL format.

    Or Azure Application Gateway to rewrite the URL.
    According to the documentation, you can create a rewrite rule with a condition that evaluates if the location header matches a specific pattern, and then rewrite the location header to a different value.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search