File Path

N

news.microsoft.com

Hi,
I have an ASP.NET web site and another project (a class library) which is
referenced in the web site.
I want to send the relative path from the web site to the dll (the class
library), because I generate a file with dll project.
How can I do this?

Regards,
Mystique
 
R

Rad [Visual C# MVP]

Hi,
I have an ASP.NET web site and another project (a class library) which is
referenced in the web site.
I want to send the relative path from the web site to the dll (the class
library), because I generate a file with dll project.
How can I do this?

Regards,
Mystique

You can use Server.MapPath() to get the absolute URL of a file on the
website and pass that to your DLL
 
M

Mythran

news.microsoft.com said:
Hi,
I have an ASP.NET web site and another project (a class library) which is
referenced in the web site.
I want to send the relative path from the web site to the dll (the class
library), because I generate a file with dll project.
How can I do this?

Regards,
Mystique

If your class library has a reference to System.Web, you could use the
following:

using System.Web;
using System.Web.UI;
public class TestWebClass
{
private Page CurrentPage {
get {
return HttpContext.Current.Handler as Page;
}
}

public string GetWebAppRoot() {
if (this.CurrentPage is null) return string.Empty;
return this.CurrentPage.Request.ApplicationPath;
}

public string GetCurrentPagePath() {
if (this.CurrentPage is null) return string.Empty;
return this.CurrentPage.Request.Path;
}
}

This is typed up, so may not compile due to typos...otherwise, should work
fine.

HTH,
Mythran
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,276
Latest member
Sawatmakal

Latest Threads

Top