Request.AplicattionPath drop server name

Hi All,

I used Request.ApplicationPath for referencing my documents upload directory . It worked great in my dev environment. However, when I copied the project to my production server, the reference is completely removing the server name.However, on production, the document reference is set to http://upload/mydoc.doc

You can see that it is dropping the server name completely.

-1
esquima
5/4/2009 10:00:18 PM
asp.net.web-forms 93655 articles. 3 followers. Follow

1 Replies
888 Views

Similar Articles

[PageSpeed] 18

If you read the definition of Request.ApplicationPath, it says "Use this property to construct a URL relative to the application root from a page or Web user control that is not in the root directory. This allows pages and shared controls that exist at different levels of a directory structure to use the same code to link to resources at fixed locations in the application."

Here's a much more reliable way to obtain full qualified http URL:   

string fullApplicationPath = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + HttpContext.Current.Request.ApplicationPath + "/"; // using UriPartial.Authorith handles correct http scheme, i.e.: 'http' and 'https'
 
Jack Yang
.NET Developer
1
jackyang
5/4/2009 11:16:40 PM
Reply:

Similar Artilces:

add/change name/delete server files via vb.net web form
I have the add(upload) part of this page figured out. I have an application with an "Images" sub directory. I know how to access the getfiles() method from the system.IO namespace. I am using a while loop to create a table with an edit button (so that you can change the name of the file) and a delete button so you can remove the file from the server. Each file is on a new line much like it would look if it was bound to a datalist or datagrid. Here is where I am clueless. Can anyone point me in the right direction? I am not looking for someone to write this for me, beca...

Drag and Drop from Solution Explorer onto Web Form doesn't drop object but drops file name instead
I can't seem to figure out why, when I drag and drop a user control from Solution Explorer onto my Web Form that the filename, including the directory spec., is dropped on the form rather than the object itself.  This is also true when I drag and drop onto the toolbox.  I can't seem to figure this one out... Hi MichelleBaker, From your description, I understand that when you drag and drop a user control from Solution Explorer to your aspx page, instead of getting a user control instance, you can only get the link with file path of the user control. If there has been any ...

Error When Debugging (Unable to start debugging on the web server. Unable to connect to the web server. Varify that the web server is running and that incoming HTTP request are not blocked by a firewa
Hi, When im going to run asp.net website its giving this error. Unable to start debugging on the web server. Unable to connect to the web server. Varify that the web server is running and that incoming HTTP request are not blocked by a firewall.  please help me to solve this problem. Thank you. Pubudu  If you are running your site off of a different machine than you are developing on, you need to install and configure the Visual Studio Remote Debugger on that machine. try to change the address from http://localhost to http://yourIP...   i hope it's worked...mak...

Implementing .Net Form into an APS.net web form, can this be done
I am new here, but have been searching for a while, and may not have the correct lingo to find what I am looking for.  I am tasked with implementing a .exe application that was writen vb6 then converted to .net into a new website my team is developing. The idea is to put each of the 3 different forms in this .exe application of 3 different .aspx pages. I have attempted multiple things to get this into the page and even started to just rewrite it as an ASP.net web form, but even then I can't reuse any of the code since the System.Web.UI.Page doesn't inherit the sa...

Unable to start debugging on the web server. The web server could not find the requested resource
Hi When i try to compile/debug my application i get this popup error. Unable to start debugging on the web server. The web server could not find the requested resource Does anybody know know how to resolve this?   Regards Macker       did you look at this article http://msdn2.microsoft.com/en-us/library/ms165025(VS.80).aspxKumar Reddi No   But i will have a look at it and see if that fixes my problem   Thanks I had this problem in VS 2005 when the IDE was viewing an xml file.  I would press F5 to start debugging and it would show t...

Deploying Vb.Net Web Forms on the server
I created a setup file for my first test Web Application. It has a few forms that I like to test on the server. What do I have to do on the server for it to work properly. I have it working on my dev machine. What do I have to install and is there any changes that I have to make to machine.config or any other files. I am using the default settings in Global and web.config files. These files were generated by the Vb.Net 2003. I have been reading on this for awhile and like to make sure of the steps I have to follow. Any help will be greatly appreciated....

aspx form works in Visual Studio web server but not on my main IIS web server.
Hi all,  I have a simple form that works fine in the VS local web server but when I copy the files (index.aspx, index.aspx.vb, web.config) to my IIS server I can see the form but when I click the hyperlink the form doesn't work. It is as if the .aspx can't execute the .aspx.vb page. Any ideas why this would be?  This is my first asp.net project so I am a complete novice here. Thanks.  My aspx code: <%@ Page Language="VB" AutoEventWireup="false" CodeFile="login.aspx.vb" Inherits="Default2" %> <html xmlns=...

superreview requested: [Bug 288906] Return null for MSAA name when no name explicitly set for HTML form control : [Attachment 179538] If no name explictly set for form control, use SetIsVoid(null)
Aaron Leventhal <aaronleventhal@moonset.net> has asked neil@parkwaycc.co.uk <neil.parkwaycc.co.uk@myrealbox.com> for superreview: Bug 288906: Return null for MSAA name when no name explicitly set for HTML form control https://bugzilla.mozilla.org/show_bug.cgi?id=288906 Attachment 179538: If no name explictly set for form control, use SetIsVoid(null) https://bugzilla.mozilla.org/attachment.cgi?id=179538&action=edit ...

Web form on two web servers
Hi,  Consider a website which is composed of two webforms (for example in two frames) and each one is hosted on a different web server. Is there an easy and secure way to make them share state information with each other? For example, I would like one form to display a picture only if the user can answer a skill testing question in the other form. So form A somehow has to tell form B that it should reload with the picture enabled. I don't want to do it via a cookie on the user's computer, because then the user might be able to fake the cookie and get the picture without answering ...

Unable to start debugging. Unable to connect to the web server. Verify the web server is running and that incoming HTP requests are not blocked by a firewall.
I have been using ASP.net 2.0 VS 2005 express edition c# on a single machine with IIS 5.1. Browser is MS IE 7.0. There have been no problems until a few days ago.   Debugging works 30% of the time, albeit very slowly. 70% of the time I get this message: "Unable to start debugging. Unable to connect to the web server. Verify the web server is running and that incoming HTP requests are not blocked by a firewall." This happens for old and new websites alike.   I have: stopped firewalls with no impact. de-registered and registered ASP 2....

Access local server(LAN Server) from Web Server(Web Application Server)
Hello All I have a local server for my LAN and a Web server(at remote location).Is it possible to access my Local Server from my Web Server ? Thanks MS  ...

superreview requested: [Bug 410500] Add "Web form password" description to web form keychain items : [Attachment 295140] fix
Stuart Morgan <stuart.morgan@alumni.case.edu> has asked Mark Mentovai <mark@moxienet.com> for superreview: Bug 410500: Add "Web form password" description to web form keychain items https://bugzilla.mozilla.org/show_bug.cgi?id=410500 Attachment 295140: fix https://bugzilla.mozilla.org/attachment.cgi?id=295140&action=edit ...

request.form & variable form name
I have a page which contains a form which will have a variable number of textboxes for the user to complete. The text boxes are called (for arguements sake) Textbox1, Textbox2, Textbox3 etc I was intending to create a Do.... Loop using a counter and variable to create the textbox name and then use this variable in the request.form command  -  see below as an example of what I am trying to say.             Dim loopcount As Integer = 1            Dim item_IDs As Str...

Is there any possible way that forms authentication can work on a web farm w/o each servers machine key values being set to the same thing?i have a site that is on a web farm and the servers dont have
 Is there any possible way that forms authentication can work on a web farm w/o each servers machine key values being set to the same thing?i have a site that is on a web farm and the servers dont have the machine keys set......but the forms authentication works fine. "Only when we are no longer afraid do we begin to live" -D. Thompson // f bush. ----------- "No man succeeds without a good woman behind him. Wife or mother, if it is both, he is twice blessed indeed." -Harold MacMillan A couple of things spring to mind. 1. Some form of "st...