简体   繁体   中英

ASP.NET application using the wrong file path when publishing to a windows server 2008 machine

I have an asp.net application that i am modifying. I setup visual studio 2010 to publish to are development server which is running windows server 2008 RC 2 (dont think it matters). I added a new webform to the application through visual studios "add new item" feature and it works on my local computer. When i publish to the server, it starts to throw cryptographic exceptions because its trying to access a.p12 file in order to send apple push notifications to an iphone device. I thought it was something wrong with the certificate at first so i added print statements to the code and noticed it is trying to access the new page at the file path on my local machine instead of the file path on the server. Does anyone have any ideas on why its doing that? Is there a way to make the file path relative to the project?

Server does not matter. The file was added with an absolute path. Not sure why and don't have the time to research.

How is the site set up on your debug machine? Are you using IIS or the ASP.NET development server? Not sure if this makes a big deal, but switching to IIS and better mimicking production often solves these little snit type of errors. To switch, add the folder to IIS, then remove the project and re-include with the HTTP path instead of the project folder.

If local IIS is not an option, or you already have done that, I would do a search for the path in question and alter it there. If you find no results, this could we be embedded in the solution file some how.

You have to use MapPath("{relativePath/FileName}"). This will return a physical path.

filename = MapPath("/images/logo.jpg")

Would something along the lines of "C:\inetpub\webroot\images\logo.jpg"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM