0

I'm maintaining an old ASP.NET web application that runs on our company network.

I have moved it across from an old Windows Server 2003 R2 to a Windows Server 2012 R2.

In it there is a GridView with a column of HyperlinkField's which take their links from an object's properties based on other data in the session and point to .pdf files on the server.

In the code there are these strings:

FileLoc = "D:\Manufacturing\Production Engineering\Production Drawings\"

ServerFileLoc = "/Production/Production Drawings/"

So I assumed that a virtual directory was set up in IIS.

In IIS Manager I created a new Website and in that website I added an application which points to the root folder of the web app. I then created a virtual directory in the web site which points to "D:\Manufacturing\Production Engineering" and named it "Production" but when I run the web site and click on the links it adds the URL to the end of the root directory of the app and I get an error stating :

Requested URL http://localhost:62322/Production/Production Drawings/PD1067250000 ACT20P Bridge Housing Assembly 10-09-09.pdf

Physical Path D:\Design Development Engineering\Engineering\Database\Products\Production\Production Drawings\PD1067250000 ACT20P Bridge Housing Assembly 10-09-09.pdf

D:\Design Development Engineering\Engineering\Database\Products is the root directory of the web app.

How do I stop it from adding the root directory at the beginning?

Is there something I have not set up correctly in IIS for the virtual directory to work?

MILO
  • 195
  • 1
  • 2
  • 11
  • How do you resolve the path? Where is the application deployed? Virtual directories affect the URLs, not how physical paths are treated. Unless you use [Server.MapPath](https://learn.microsoft.com/en-us/dotnet/api/system.web.httpserverutility.mappath?view=netframework-4.8) a relative path is *always* converted to a physical path using the application's current folder – Panagiotis Kanavos Jun 10 '20 at 06:50
  • It looks like you deployed the application to a different folder, created a virtual directory pointing to another one and the application's code use relative paths without mapping. Or you thought that by creating an unrelated virtual directory the application would read from a different physical folder? – Panagiotis Kanavos Jun 10 '20 at 06:51
  • I'm developing on the actual server, the app is where I stated above. I tried using Server.MapPath() and it wouldn't create the hyperlinks, they would just display as text. How do I get it to access a folder that is above the root directory of the Web app? – MILO Jun 10 '20 at 07:47
  • Web dev is NOT my thing at all. So I'm probably doing everything totally wrong, I'm just trying to look through the code and figure it out and if possible get it all working. It was written about 13 years ago and I've just been trying to make it run on a newer version of the .NET framework and on a newer server. – MILO Jun 10 '20 at 08:09
  • @typedefMiles_WilliamsMILO You mention setting up the virtual directory in IIS, then later I see a port number 62322. Does that mean that you are using IIS Express for development? **If so**, it would probably be easier to use IIS (assuming you can get Administrator access on your PC); otherwise [Creating virtual directories in IIS express](https://stackoverflow.com/q/8735713/1115360) might help. – Andrew Morton Jun 10 '20 at 08:50
  • @Andrew Morton Actually I tried to use IIS Express in Visual Studio as well as running the Web app as a service in actual IIS and just opening the index.htm file in a browser. Like I said Web dev is not my thing, I just happen to be the only person in the company with any coding knowledge. I'm developing on the server that it will be running on. I have a remote desktop connection to the server if that makes a difference. – MILO Jun 10 '20 at 10:01

0 Answers0