473,695 Members | 2,599 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Server.MapPath( "/") doesnt work

When using Server.MapPath on IIS 5 on my localhost everything works
well. All of the following commands are executed without any error

Response.Write( Server.MapPath( "/app_test") & "<br>")
Response.Write( Server.MapPath( "app_test") & "<br>")
Response.Write( Server.MapPath( "~") & "<br>")

However, running the first statement on via the internal Visual Studio
2005 Server I receive an error for

Server.MapPath( "/app_test")

Source File: C:\Documents and Settings\machin e.namei\My Documents
\Visual Studio 2005\WebSites\t esting\phishing Pics\Default2.a spx.vb
Line: 10

Stack Trace:
[InvalidOperatio nException: Failed to map the path '/app_test'.]
System.Web.Host ing.HostingEnvi ronment.MapPath Actual(VirtualP ath
virtualPath, Boolean permitNull) +3521356
System.Web.Virt ualPath.MapPath Internal() +41
System

What can I do to make this work on my testing enviroment with the
light weight webserver on Visual Studio 2005

Feb 12 '07 #1
5 9619
MichiMichi wrote:
When using Server.MapPath on IIS 5 on my localhost everything works
well. All of the following commands are executed without any error

Response.Write( Server.MapPath( "/app_test") & "<br>")
Response.Write( Server.MapPath( "app_test") & "<br>")
Response.Write( Server.MapPath( "~") & "<br>")

However, running the first statement on via the internal Visual Studio
2005 Server I receive an error for

Server.MapPath( "/app_test")

Source File: C:\Documents and Settings\machin e.namei\My Documents
\Visual Studio 2005\WebSites\t esting\phishing Pics\Default2.a spx.vb
Line: 10

Stack Trace:
[InvalidOperatio nException: Failed to map the path '/app_test'.]
System.Web.Host ing.HostingEnvi ronment.MapPath Actual(VirtualP ath
virtualPath, Boolean permitNull) +3521356
System.Web.Virt ualPath.MapPath Internal() +41
System

What can I do to make this work on my testing enviroment with the
light weight webserver on Visual Studio 2005
Do you need to use that exact path? What folder is it that you want to
reach?

--
Göran Andersson
_____
http://www.guffa.com
Feb 12 '07 #2
I want to reach the root folder of my web application.

Response.Write( Server.MapPath( "~") works fine but I thought it also
would work with Response.Write( Server.MapPath( "/") but it doesnt?

It works on IIS but not with the intern web server of VS2005

On Feb 12, 4:49 am, Göran Andersson <g...@guffa.com wrote:
MichiMichi wrote:
When using Server.MapPath on IIS 5 on my localhost everything works
well. All of the following commands are executed without any error
Response.Write( Server.MapPath( "/app_test") & "<br>")
Response.Write( Server.MapPath( "app_test") & "<br>")
Response.Write( Server.MapPath( "~") & "<br>")
However, running the first statement on via the internal Visual Studio
2005 Server I receive an error for
Server.MapPath( "/app_test")
Source File: C:\Documents and Settings\machin e.namei\My Documents
\Visual Studio 2005\WebSites\t esting\phishing Pics\Default2.a spx.vb
Line: 10
Stack Trace:
[InvalidOperatio nException: Failed to map the path '/app_test'.]
System.Web.Host ing.HostingEnvi ronment.MapPath Actual(VirtualP ath
virtualPath, Boolean permitNull) +3521356
System.Web.Virt ualPath.MapPath Internal() +41
System
What can I do to make this work on my testing enviroment with the
light weight webserver on Visual Studio 2005

Do you need to use that exact path? What folder is it that you want to
reach?

--
Göran Andersson
_____http://www.guffa.com

Feb 12 '07 #3
Why not use the method that works? The old method doesn't work because a
path beginning with a forward-slash is a site-root relative path. An ASP.Net
application is not a (web) site root. It is simply a designation of a
virtual directory as housing resources that will be processed in the same
application domain (memory space). The tilde ('~') indicates that the path
is relative to the application root.

--
HTH,

Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com

The shortest distance between 2 points is a curve.

"MichiMichi " <ww*****@gmx.ch wrote in message
news:11******** **************@ q2g2000cwa.goog legroups.com...
I want to reach the root folder of my web application.

Response.Write( Server.MapPath( "~") works fine but I thought it also
would work with Response.Write( Server.MapPath( "/") but it doesnt?

It works on IIS but not with the intern web server of VS2005

On Feb 12, 4:49 am, Göran Andersson <g...@guffa.com wrote:
MichiMichi wrote:
When using Server.MapPath on IIS 5 on my localhost everything works
well. All of the following commands are executed without any error
Response.Write( Server.MapPath( "/app_test") & "<br>")
Response.Write( Server.MapPath( "app_test") & "<br>")
Response.Write( Server.MapPath( "~") & "<br>")
However, running the first statement on via the internal Visual Studio
2005 Server I receive an error for
Server.MapPath( "/app_test")
Source File: C:\Documents and Settings\machin e.namei\My Documents
\Visual Studio 2005\WebSites\t esting\phishing Pics\Default2.a spx.vb
Line: 10
Stack Trace:
[InvalidOperatio nException: Failed to map the path '/app_test'.]
System.Web.Host ing.HostingEnvi ronment.MapPath Actual(VirtualP ath
virtualPath, Boolean permitNull) +3521356
System.Web.Virt ualPath.MapPath Internal() +41
System
What can I do to make this work on my testing enviroment with the
light weight webserver on Visual Studio 2005

Do you need to use that exact path? What folder is it that you want to
reach?

--
Göran Andersson
_____http://www.guffa.com


Feb 12 '07 #4
MichiMichi wrote:
I want to reach the root folder of my web application.
Then you should use "~", not "/".

If you use "/" you will get to the root folder of the web site, but if
your application is in a virtual folder, you will get the wrong address.
Response.Write( Server.MapPath( "~") works fine but I thought it also
would work with Response.Write( Server.MapPath( "/") but it doesnt?

It works on IIS but not with the intern web server of VS2005

On Feb 12, 4:49 am, Göran Andersson <g...@guffa.com wrote:
>MichiMichi wrote:
>>When using Server.MapPath on IIS 5 on my localhost everything works
well. All of the following commands are executed without any error
Response.Writ e(Server.MapPat h("/app_test") & "<br>")
Response.Writ e(Server.MapPat h("app_test") & "<br>")
Response.Writ e(Server.MapPat h("~") & "<br>")
However, running the first statement on via the internal Visual Studio
2005 Server I receive an error for
Server.MapPat h("/app_test")
Source File: C:\Documents and Settings\machin e.namei\My Documents
\Visual Studio 2005\WebSites\t esting\phishing Pics\Default2.a spx.vb
Line: 10
Stack Trace:
[InvalidOperatio nException: Failed to map the path '/app_test'.]
System.Web.Host ing.HostingEnvi ronment.MapPath Actual(VirtualP ath
virtualPath , Boolean permitNull) +3521356
System.Web.Virt ualPath.MapPath Internal() +41
System
What can I do to make this work on my testing enviroment with the
light weight webserver on Visual Studio 2005
Do you need to use that exact path? What folder is it that you want to
reach?

--
Göran Andersson
_____http://www.guffa.com


--
Göran Andersson
_____
http://www.guffa.com
Feb 12 '07 #5
I am now using the "~" instead of "/".

Microsoft should change its documentation as well.

Thanks for helping.
On Feb 12, 1:29 pm, Göran Andersson <g...@guffa.com wrote:
MichiMichi wrote:
I want to reach the root folder of my web application.

Then you should use "~", not "/".

If you use "/" you will get to the root folder of the web site, but if
your application is in a virtual folder, you will get the wrong address.
Response.Write( Server.MapPath( "~") works fine but I thought it also
would work with Response.Write( Server.MapPath( "/") but it doesnt?
It works on IIS but not with the intern web server of VS2005
On Feb 12, 4:49 am, Göran Andersson <g...@guffa.com wrote:
MichiMichi wrote:
When using Server.MapPath on IIS 5 on my localhost everything works
well. All of the following commands are executed without any error
Response.Write (Server.MapPath ("/app_test") & "<br>")
Response.Write (Server.MapPath ("app_test") & "<br>")
Response.Write (Server.MapPath ("~") & "<br>")
However, running the first statement on via the internal Visual Studio
2005 Server I receive an error for
Server.MapPath ("/app_test")
Source File: C:\Documents and Settings\machin e.namei\My Documents
\Visual Studio 2005\WebSites\t esting\phishing Pics\Default2.a spx.vb
Line: 10
Stack Trace:
[InvalidOperatio nException: Failed to map the path '/app_test'.]
System.Web.Host ing.HostingEnvi ronment.MapPath Actual(VirtualP ath
virtualPath, Boolean permitNull) +3521356
System.Web.Virt ualPath.MapPath Internal() +41
System
What can I do to make this work on my testing enviroment with the
light weight webserver on Visual Studio 2005
Do you need to use that exact path? What folder is it that you want to
reach?
--
Göran Andersson
_____http://www.guffa.com

--
Göran Andersson
_____http://www.guffa.com

Feb 14 '07 #6

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

Similar topics

11
13272
by: Ellen K | last post by:
Hi all, I set up our Oracle Financials as a linked server to one of my SQL Server boxes. On running a test query, I got the following error message: OLE DB provider 'MSDAORA' supplied inconsistent metadata for a column. Metadata information was changed at execution time. OLE DB error trace . The Oracle datatype of the column with the supposedly inconsistent
3
6206
by: Mikkky | last post by:
The sample code below returns and error " The type or namspace name 'Server' could not be found". Please help. using System;using System.IO; using System.Xml;using System.Diagnostics; using System.Collections;using System.Web;using System.Web.UI; using System.Web.UI.WebControls;using System.Web.UI.HtmlControls; public class Business { XmlDocument doc = new XmlDocument(); doc.Load(Server.MapPath("Rules.xml"));
4
9412
by: ramonred | last post by:
txtUpload1.PostedFile.SaveAs(Server.MapPath("~") + "\\" + file1.Name); this code loads the file in the root directory of my application, by using the tilde. How do I accomplish getting the file to loaded above root. My application is within another applilcation (subdomain). I guess I am looking the .net equivalent to .. in unix. Thanks.
1
1818
by: Jim Heavey | last post by:
Hello, I am trying out how to programatically figure out where my datafile is. I thought I could use Server.MapPath to provide me the name of where my webpage is located, as I have used that in other situations, but this situation is different. My web pages and data file do not reside on the same drive as where the server resides, so Sever.MapPath is propbably not the right method. How do I find the path where my actual web page is...
2
3796
by: Tee | last post by:
Hi, I am currently using Server.MapPath in my aspx files, but because of I am using it more than once, I would like to move these code away from aspx and make it as a public function inside Module, but I am having problem with it. As "Server.MapPath" is not allow in other .vb file ... can anyone help with this ? or if we really can't make it, is there any other way could do it ? Thanks,
2
3047
by: Jim Moon | last post by:
Hello. We have SQL Server Stored Procedures that use the "CURRENT_USER" variable. We have SQL Server database fields that call "user_name()" as a default. That has been fine in the use and storage of user names, in the context of being called from IIS 5 and 6, from ASP 3.0 using ADODB. I'll add that the web applications are using Basic Authentication. So, individual user account names are garnered and stored. That is valuable to us.
10
9034
by: Kenneth P | last post by:
Hi all, I have an Access database and try to create a connection to it using the Server.MapPath method. I have the app lib in c:\inetprub\wwwroot\apps\myApp and the database in c:\inetpub\dbq\myDB. Using Server.MapPath("../../../dbq/myDB") should as I understand it take me to the myDB lib. But instead I get an error message saying "Cannot use a leading .. to exit above the top directory."
1
1900
by: ae | last post by:
is the prope way to read xml files, as long as they are on my server, but how do i access them from other sites, such as http://www.site.com/xmltoread.xm
1
1949
by: varathasiva | last post by:
Dear All, I am new in MySQL.I installed mysql-5.0.51b-win32 version.How to configure in MySQL server work as local network or remote server.PostgreSQL we did configuration in pghba.conf host all all 0.0.0.0 0.0.0.0 md5.How we can do settings in MySQL 5.0 server.Please Help me.Advance thanks to all. Kindly Regards varathasiva
0
8619
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
9112
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8818
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
7652
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
6487
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
4338
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
4575
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2996
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
1971
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.