Get Absolute URL – Web Application

Getting fully qualified absolute path of ASP.NET application is always tricky and problem arises when code moves across various platform. Hard coding the Application Path is no where a good solution here.

The URL syntax is:

Two solutions that you can look for in such scenarios:

1. Add an entry in your web.config file and use it across your application.

So, you need to change this entry at various platforms as code moves along.
2. Programmatically, construct you application path from HTTP Request object.

This code will automatically picks up appropriate path and no intervention is needed.