Web Forms :: How To Return A Relative Path
Apr 19, 2010
what it does at the moment is return an absolute path for example h:myfile . however, this is causing me problems because when browsing to the page, it is not returning the file i need because it is looking for a h: drive which the client machine does not have. so i was thinking i need to return a relative path so the not looking straight to the h: drive and rather it is just looking for the filename. i have also created this as a virtual directory on iis which is where is looks for the file location.
View 8 Replies
Similar Messages:
Apr 8, 2010
I am Final Year IT Engineering student. I am Doing Content Management System in ASP.net for my college. I have given link on my master page for various pages in the application; where I have specified only relative path of those pages. When I run this project and follow any link it works well for only first time and for second time when I click any link it .net run time environment unable to find the absolute address of that page.
View 2 Replies
Apr 4, 2010
I have this master page, that uses a few .js files and a flash animation.
the <script> and <object> tags that are used to embed these in the page take in relative paths as src. However, since the pages .aspx, i'll need to convert these into tilde paths, ie. somehow change the relative paths to tilde path (is this the absolute path?), so that i can use the master page in any of my pages in subfolders as well. if this question has been posted b4, kindly give me a link... i've not been able to find a solution.
View 3 Replies
Jun 9, 2010
When I write following code in my view
<% Url.Action("Logon") %>
the mvc framework generates
/Account/Logon ({controller}/{action})
as path.
'/Account/Logon' path is an absolute path. Is there a way to change is to a relative path, like Account/Logon or ../Account/Logon.
Also, when I use the Html.Beginform(), the mvc framework generates <form action="/account/logon"..., I want to change this to <form action="account/logon"...So, problem is that I want relative paths instead of absolute path.
View 6 Replies
Oct 13, 2010
i am fetching image using webservice into dataset and displaying for that its to be get worked after deployment i have done following line of code but its still not able to display the image after deployment
String imageName = row["ImageName"].ToString();
String physicalPath = HttpContext.Current.Request.Url.AbsoluteUri.ToString();
String imagePath = physicalPath.Substring(0, physicalPath.LastIndexOf("/",
StringComparison.OrdinalIgnoreCase) + 1) + imageName;
View 3 Replies
Jul 22, 2010
I have got a master page(Project>>MasterPages>>MainPage.master) and some images in that page with some path like "../../Images/bg_main_menu.png".
I refer this master page in two forms. One of those form is oresent in the path :
Project>>Forms>>Form1.aspx and the other one is : Project>>Forms>>NewFolder>>Form2.aspx
Now for Form2.aspx the image is not getting loaded.
I tried the image path with "~Images/bg_main_menu.png". But it is not working.
View 2 Replies
May 4, 2010
I have a web application that uses Server.MapPath to specify the exact physical path of as part of upload image.
For example if I do Server.MapPath("/")
I get this:
\boswinfs04homeusersweb2676username
I was expecting something like this:
d:folder
I need to use Server.MapPath not only for image upload but several other uses.
View 2 Replies
Sep 9, 2010
How do you calculate a relative path in ASP.NET MVC?
View 2 Replies
Jun 21, 2010
I've got this app where I'm using an IHttpHandler to serve JSON data to my JavaScript method.
[code]....
This works fine on my "localhost" webserver, but I've also got a staging server for my clients to use. http://staging.infinitas.ws/ClientSite/
The problem that I'm having is that when the app is hosted on the staging server, the theSource is mapped incorrectly (contains /ClientSite/). I could do something like a String.Replace but I'm looking for a more elegant way of achieving this.
View 1 Replies
Apr 24, 2010
I am trying to get a FileStream from a relative path. The file is in my project, but when I try to do that it automatically appends C:\ in front of that.
1. Does the FileStream only works if the file is on a local Hard Dive?
2. Also if it works from the local hard drive, then does my application needs some permission to read the file from C Drive?
View 2 Replies
Dec 14, 2010
Possible Duplicate: Absolute path & Relative Path
When to use absolute path, relative path and what is the difference between both?
View 2 Replies
Sep 20, 2010
I have three projects inside my solution and i using some same images on all of three projects. How can i create relative path from one project to another?
View 4 Replies
Oct 6, 2010
Assuming I have a .css file with the following linebody { background-image: url('../images/bg.png') }My build process does some CSS magic and eventuall move this file from
~/Content/styles/styles.css
To
~/temp/styles.css
This invalidates the url statement in the file and needs re-written to ../Content/images/bg.pngThis is my question - given the original file location, the new file location and the background-image url in the file is there a reusable way calculate a new relative path for the image?In case someone doesn't know css urls should be relative to the css file it is contained within.
View 2 Replies
Dec 7, 2010
my asp.net program have to open pdf files, these files are contained in a directory named "pdf",
The problem is: The webpage doesn't find the relative directory "/pdf" ; to solve the problem I have to write the exaclty path "C:inetpubwwrootsitepdf" butI want to use only the relative path to avoid other problems.
View 1 Replies
May 6, 2010
I have an XML file named PageData.xml in my App_Data folder. I want to populate an XDocument with this file using XDocument.Load.
If I supply the full physical path it works, i.e.:
XDocument vXDoc = XDocument.Load("/Work/Project/Web/100413 Dev/App_Data/PageData.xml");
...where "Work" is a folder on my C: drive.
If I try a relative path like this, though, I get a DirectoryNotFoundException:
XDocument vXDoc = XDocument.Load("AppData/PageData.xml");
"Could not find a part of the path 'C:Program Files (x86)Common FilesMicrosoft SharedDevServer10.0AppDataPageData.xml'."
This is obviously wrong, but there must be an easy way to set the correct relative path?
View 1 Replies
Oct 29, 2010
OK, I've seen a lot of ambiguous errors, but this was is in the top 20 or so. I have a RenderPartial that looks like this:
[Code]....
When the view loads, I get this error:
The relative virtual path '~Areas/User/Views/Shared/ProjectStats.ascx' is not allowed here. That really helps. Why isn't it allowed there? What's wrong with it? Just above it I have other PartialRender calls that work without a problem. They're created exactly the same way. Here's another:
[Code]....
This works fine. I thought maybe it was due to accessing a view from another Area, but I added a partial view to that Area's folder and it still didn't work.
View 3 Replies
Jan 22, 2010
i would know if is possible and how i can retrieve the current relative path of the view that is executed. The code is in a model file (C#)
View 2 Replies
Jan 22, 2010
Suppose I have a resource located in ~/Resources/R1.png This resource's relative URL will vary depending on the current address.
For instance: If I'm at www.foo.com/A/B/C/D.aspx and the www.foo.com/A is the root path including Virtual Directory, then the path relative to the current address of ~/Resources/R1.png is ../../../Resources/R1.png
How can I get this relative path?
EDIT:
I want a web path that I can use in a web page, not a server path.
View 4 Replies
Sep 7, 2010
I have to access a relative path of the XSD file to validate a XML file. The XML file and the XSD file are part of the class library. How do I access the relative path in the class library?
In case of website, I would use server.mappath(path). Is there anything similar to get the virtual path to the corresponding physical directory on the server in the class library?
View 2 Replies
Oct 8, 2010
I am doing SOA architecture and the data base is in service side ie.within the project(website 7)
how can i can mention relative path for the data source ?
OleDbConnection aConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\sathiyabalu\My Documents\Visual Studio 2005\WebSites\WebSite7\App_Data\alumni_member.mdb");
View 1 Replies
May 19, 2010
I have ASMX services for my web application that I would only like available to the same application.Is there a way for the web service to only be accessible by the same application, such as relative/absolute path restrictions?
View 3 Replies
Mar 10, 2011
I'm working with an ASP.net web application.I've written a user control called LocationSelector that has its own Javascript in an external .js file. In order to load that file, I use the following line of code:
ScriptManager.RegisterClientScriptInclude(this, typeof(LocationSelector), Guid.NewGuid().ToString(), "Controls/LocationSelector.js");
The problem is with "Controls/LocationSelector.js". As long as the page that uses the control is in the root directory of the application, everything works. However, as soon as I try to put this control in a page in a subdirectory, it can't load the Javascript file.
View 1 Replies
Feb 12, 2010
Question about paths while working in Visual Studio. In my master page I have some paths to load css files as well as javascript files.
My first question is if I use relative paths, should the relative path be from the location of the master page file? For example if I keep all my master page files in a folder off the site root called MasterPages should I assume that is the starting point for my relative paths to load the css files? If that master page is used to wrap an aspx file several directories down the tree is the hard coded relative path still valid?
Second question, is there a way to use absolute paths so that everything works on my local machine as well as when I move the files up to the webroot? For example my app path on my local machine may be localhost/myappdir/default.aspx but when i move the app to the server there is no myappdir and the default.aspx is in the webroot. I do not want to have to change paths in the files after they are moved up to the server. currently I have;
src="<%= VirtualPathUtility.ToAbsolute("~/lib/css/style.css")%>"
but this way Visual Studio cannot find the css file to update intellisence
View 4 Replies
Sep 9, 2010
I am really surprised that there is no native .NET method to get an absolute url from a relative url. I know this has been discussed many times, but never have come across a satisfactory method that handles this well. I think all I need left is to auto choose the protocol instead of hard coding it (http/https). Anything else I am missing (caveats, performance, etc)?
public static string GetAbsoluteUrl(string url)
{
//VALIDATE INPUT FOR ALREADY ABSOLUTE URL
if (url.StartsWith("http://", StringComparison.OrdinalIgnoreCase) || url.StartsWith("https://", StringComparison.OrdinalIgnoreCase))
{
return url;
}
//GET PAGE REFERENCE FOR CONTEXT PROCESSING
Page page = HttpContext.Current.Handler as Page;
//RESOLVE PATH FOR APPLICATION BEFORE PROCESSING
if (url.StartsWith("~/"))
{
url = page.ResolveUrl(url);
}
//BUILD AND RETURN ABSOLUTE URL
return "http://" + page.Request.ServerVariables["SERVER_NAME"] + "/" + url.TrimStart('/');
}
View 6 Replies
Jul 1, 2010
I'm venturing into the world of Microsoft Reporting Services for the first time. So far it's gone pretty well, but I do have a couple of questions. The biggest one is, can I get the ReportViewer to use a relative path to my .rdlc file instead of the full path name that it seems insistent on using? When I'm developing locally oh my desktop, my filepath is c:inetputwwwrootcascadewritingwritingresults.rdlc; however, when I move this to production the filepath will become :websitecascadewritingwritingresults.rdlc. The .aspx page that my ReportViewer is embedded in resides in the same directory as the .rdlc file itself, so I was hoping I could just simply chop off the path altogether and reference the file name, but when I do ReportViewer fusses at me and says it can't find the file.
An error occurred during local report processing.
The report definition for report 'c:inetpubwwwrootCascadeWritingResults.rdlc' has not been specified
Could not find file 'c:inetpubwwwrootCascadeWritingResults.rdlc'.
In case you need/want to see it, my code for the ReportViewer is below:
[Code]....
View 3 Replies