473,722 Members | 2,430 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Change in MapPath in ASPNET2?

I'm running into a repeatable oddity in porting a bunch of ASPNET1.1 websites to ASPNET2. Calls like this:

MapPath("/path/fromroot")

result in exceptions under ASPNET2, but worked fine under ASPNET1.1.

Changing the calls to:

MapPath("~/path/fromroot")

makes them work again under ASPNET2.

Is this a design change? Or perhaps an artifact of using the "bundled" webserver in VS2005? I used to debug on a test server that
was separate from my development machine. Now, under VS2005, I do everything on the development machine.

- Mark
Feb 25 '06 #1
5 1353
Hi Mark,

Thanks for posting.

AS for the Server.MapPath function, I think the code logic of it should not
have been changed from ASP.NET 1.1 to 2.0. What's the detailed exception
message you get when call the Mappath function with the "/path/fromroot"
value or is this a machine or application specific issue?

As for "/path/fromroot" and "~/path/fromroot", they're two definite
different path. The former path start from the IIS web site's root while
the latter start from the ASPNET application's application root. Therefore,
it may result different results. Is it possible that some other code logic
in the application which use the Mappath's result cause the problem?

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Feb 27 '06 #2
Steven,

I posted elsewhere that the problem is in the way the silly testing server embedded in VS2005 handles websites. It runs all sites in
what amounts to a virtual directory of the server, for example:

Website destined to be the site for www.scef.us

Runs under embedded development server as http://local:1114/scef

See the problem? It should be running as http://local:1114, not http://local:1114/scef.

This is a big problem for anyone developing "root" websites under VS2005.

- Mark
Feb 27 '06 #3
Thanks for your response Mark,

As for the VS buildin test server, it is actually provided by the .NET
framework 2.0 in the framework dir

C:\WINDOWS\Micr osoft.NET\Frame work\v2.0.50727

named "WebDev.WebServ er.EXE". And as you mentioned, vs 2005 ide do by
default treat each ASP.NET website project as a sub virtual dir under the
root site when running them in test server. Like:

http://localhost:xxxx/ApplicationName/xxx

However, the VS 2005 ide also allow us to use the customized external test
server. You can right click your website's node in solution explorer and
choose properties menu. In the "Start options" setting, it is "use default
web server" by default, we can change it to "use custom server". For the
"Base Url", we can input the custom server's configured url we want to use,
such as
"http://localhost:7001/"

For the custom server, we can just use the WebDev.WebServe r.EXE which can
be launched externally from command line. For example, the following
command just start the Test Server which point to my vs 2005 ASP.NET
website project's project folder and configure it as Root applcation(rath er
than a sub virtual directly under root):

webdev.webserve r /port:8088
/path:"D:\users\ stcheng\workspa ce\whidbey\webs ites\TestWebSit e" /vpath:"/"

this will match the custom server's "Base Url" we configured in the ASP.NET
project above.

In addition, here is a blog article from ScottGu which have more detailed
description on this:

http://weblogs.asp.net/scottgu/archi...21/431138.aspx

Hope this helps.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


Feb 28 '06 #4
Steven,

It does help, but (and this is certainly not your issue) I think it's pretty dumb of MS to have released something that has such a
gotcha in it.

- Mark
Feb 28 '06 #5
Thanks for response.

Yes, currently it would be a limitation of the VS 2005 ide which will make
our work a bit more complex.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Mar 1 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
14320
by: John Rebbeck | last post by:
I've got the directory f:\Company\Product set as web shared so it's got a virtual directory in the default web site on my test server's IIS. If I try to use Server.MapPath in that site it returns a path within c:\Inetpub\wwwroot rather than the real path. Can anyone please tell me why this isn't working? Regards, John
1
2072
by: amber | last post by:
Hi there, I'd like to change the colour of my tabs. I can change my background colour of my tab control, but the actual tabs, with the text on them don't change colour. Am I missing something? TIA, Amber
1
2580
by: ucasesoftware | last post by:
How is it possible to change the mdi parent backcolor... this one is too dark !!
5
1404
by: Mark Olbert | last post by:
I'm starting to play around with VS2005 and ASP.NET 2 and have some questions. The typical pattern for a data-driven aspx page in v1.1 was data connection -> data adapter -> dataset -> bound controls. V2 (at least by default) doesn't include data connections, data adapters or datasets in the toolbox when building an aspx page. Nor can I find where the DataView component went to. Everything now seems to rely on the DataSource controls. ...
8
1150
by: Mark Olbert | last post by:
There appears to be a REALLY annoying bug in VS2005: periodically when you're rebuilding an ASPNET2 website which uses App_Code stuff the compiler will fail to create the dynamic assembly or not be able to copy it to the bin directory or something. In my case the error message which always shows up complains about my master page not defining a public property. The funny/sad thing is that the property is defined, and in most cases I haven't...
8
1841
by: Maxi | last post by:
Hello, i'm sorry my bad english :( I have CR9 Webservice, how to change databadse name and User_name into Webservice method? (not Viewer Control) Tks!! -- --------------------------
4
7192
by: vunet.us | last post by:
How to use server.mappath() parent folder correctly: Server.MapPath("../test.asp") Thank you for the hint.
3
15064
by: rn5a | last post by:
Server.MapPath returns the physical file path that corresponds to the specified virtual path whereas Request.MapPath maps the specified virtual path to a physical path. Assuming that a file named Hello.aspx resides in C:\Inetpub\wwwroot\MyFolder, the output of both Response.Write(Server.MapPath("Hello.aspx")) & Response.Write(Request.MapPath("Hello.aspx"))
1
2135
by: webandwe | last post by:
Hi, Can somebody please show me how to change the connection so I can make it work with my MYSQL database... I just need this login to work then I'm done wiht my project. I don't know what is going on here and is, this far from throughing my laptop into the wall..... I want to change cStr = "DRIVER={Microsoft Access Driver (*.mdb)};" cStr = cStr & "DBQ=" & Server.MapPath("\path\to\database.mdb") & ";" Conn.Open(cStr)
0
8863
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9088
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8052
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6681
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5995
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4502
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4762
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2602
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2147
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.