-1

I am having troubles with including files into my website after publishing it on server. The website is called "shop" and located in wwwroot folder. The website doesn't read scripts, which are located like this: shop/app_themes/grey/js/site.js. How to give the correct path to script files? I used ~, ../, ../../ and doesn't help..

Arunprasanth K V
  • 20,733
  • 8
  • 41
  • 71

2 Answers2

0

User Server.MapPath Methos the details are below

Server.MapPath(path) 

You can use Resolve Url method.

Example

  1. http://www.codeproject.com/Articles/205425/ASP-NET-ResolveUrl-Without-Page
  2. ResolveUrl without an ASP.NET Page
Community
  • 1
  • 1
शेखर
  • 17,412
  • 13
  • 61
  • 117
0

if u want host url then try this

public string GetHostUrl()
            {
                var request = HttpContext.Current.Request;
                var appUrl = HttpRuntime.AppDomainAppVirtualPath;

                if (appUrl == null || appUrl == "" || appUrl != "/")
                {
                    appUrl += "/";
                }

                var baseUrl = string.Format("{0}://{1}{2}", request.Url.Scheme, request.Url.Authority, appUrl);

                return baseUrl;
            }

or else you want physical path then try this

public string GetPhysicalPath()
    {
        string PhysicalPath = "";

        if (Application["instancePath"] != null && Convert.ToString(Application["instancePath"]) != "")
        {
            PhysicalPath = Convert.ToString(Application["instancePath"]);
        }
        else
        {
            PhysicalPath = Server.HtmlEncode(Request.PhysicalApplicationPath);
        }

        return PhysicalPath;
    }
}
Arunprasanth K V
  • 20,733
  • 8
  • 41
  • 71