.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

path relative

Posted By:      Posted Date: September 24, 2010    Points: 0   Category :ASP.Net

Hi to all,
I have a project in asp.net (VS2008) and I have a master page menu like this:

<li> <a href="contact.aspx"> contact </ a> </ li>
<li> <a href="archive.aspx"> archive </ a> </ li>
<li> <a href="hello/Default.aspx">story </ a> </ li>

And until they are root everything works fine.

On this site I have a folder named "hello".
When I am inside the directory "hello" (a subdirectory), the menu shows me this link:

mysite / hello / hello / default.aspx

I tried to write
<li> <a href="~/contact.aspx"> contact </ a> </ li>
<li> <a href="~/archive.aspx"> archive </ a> </ li>
<li> <a href="~/hello/Default.aspx"> story </ a> </ li>

but going on the links I get redirected here:
mysite / hello / ~ / contact.aspx
mysite / hello / ~ / archive.aspx

View Complete Post

More Related Resource Links

dllimport("mapi32.dll") changes the path context of application (i.e. relative paths start pointing

I have a WPF desktop application. We use mapi32.dll to show a new outlook mail window to allow user to send an email. After user sends email / just closes the new mail window without sending email, relative path starts pointing to C:\Program Files\Microsoft Office\Office12. I have office 2007 installed.  How can I restore this relative path ?   Thanks & Regards, Nadeem Ullah

To get the relative path in the class library

Hello, 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? Thanks

Relative path - different project


Hi there!

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?

Relative path



I have the following code in visual studio 2010:

TextBox1.Text = My.Computer.FileSystem.ReadAllText("C:\Users\Baby\Desktop\Simulator website\Resources\TextFile.txt")

It reads the text in the textfile and displays it in the textbox. However, this link only works on my computer. How do I change the code so that when published online, it still works on anybody's PC? I think i need to refer to a relative path, but do not know how this should be done.

Many thanks

Relative virtual path is not allowed here


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:


<% Html.RenderPartial("~Areas/User/Views/Shared/ProjectStats.ascx", 
           Model.ProjectSnapshots); %>

When the view loads, I get this error:

The relative virtual path '~Areas/User/Views/Shared/ProjectStats.ascx' is not allowed here.

Uh... great. 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:

<% Html.RenderPartial("~/Views/Shared/PastDueMilestones.ascx", 
                   Model.PastDueMilestones); %>

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.

Resolve relative path denoting host using a period (.\SQLExpress)



I'm trying to write code to Ping a database server to check for connectivity in the event of a SQL connection error. I'm grabbing the server name out of the database connection string, but the connection string sometimes uses a relative path such as ".\SQLExpress" with a period to denote the current machine as the host. The .NET Ping/Dns classes don't appear able to resolve "." as a machine name. I get an exception saying "No such host is known". Are there any built in classes/methods that can resolve a period to the machine name for me or do I need to write the code myself?

Virtual Path Problem


 I get the following error on last line below (working on remote host): 'E:\web\sfcascom\ls_admin/uploads/images/001.JPG' is not a valid virtual path,

Note that the slashes go in different directions

I've tried a number of things but nothing seems to work. Thanks-


Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Drawing.Imaging
Imports System.Web.UI.WebControls

Imports System.Drawing.Imaging.ImageCodecInfo
Partial Class Protected_imageupload
    Inherits System.Web.UI.Page
    Private Sub btnUpload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpload.Click
        ' Initialize variables
        Dim sSavePath As String
        Dim sThumbExtension As String
        Dim intThumbWidth As Integer
        Dim intThumbHeight As Integer
        Dim sFilename As String = ""
        ' Set constant values
        'sSavePath = "images/"
        sSavePath = Server.MapPath("~/") + "ls_admin/uploads/images/"

        sThumbExtension = "_thumb"
        intThumbWidth = 160
        intThumbHeight = 120

        ' If file field isn?t empty
        If FilUpload.PostedFile IsNot Nothing Then
            ' Check file size (mustn?t be 0)
            Dim myFile As Http

How to position one control relative to another one even after resizing windows?


I used following Jquery code trying to make image close to a table. It worked fine after first load, but the position changed after window is resized. Any ideas? thanks

$(document).ready(function() {
            var pos = $("#mytable").offset();
            var width = $("#mytable").width();
            var left = pos.left + width + 20;
            var top = pos.top + 200;
                position: 'absolute',
                zIndex: 5000,
                left: left,
                top: top

Creating a user friendly alias for the website path


 Hello mates,

I am hosting my ASP.NET application on a Windows 2003 Server.

To browse to my application one has to type the path :http://serverName/applicationName

I want users to only type  applicationName on the web adress area.I believe there is something to do with alias and CNAME on DNS records that can adress this.

Any help on how to go about doing this will be highly appreciated.

How to set SearchRoot Path in Active Directory in this scenario


How to set SearchRoot Path in Active Directory in this scenario:

Functionality: We have scenario that 1<sup>st</sup> hit one LDAP server with some 'fixed user name' &' fixed password ' and filter data with specific User name(which given by user) getting 'User dn'.

After that we hit Next LDAP server based on the 'User dn' getting from 1<sup>st</sup> server.

(So, in my case 1<sup>st</sup> LDAP server works like as Load balancing server but functionalitywise it is different)


Split URL/Path in Classic AND .net 2.0


I need to be able to get the different parts of the URI (and convert from/to relative page paths) in BOTH classic ASP and .Net 2.0 (VB).

For example, if I have "http://sitename.company.com/index.aspx?sec=fred&pag=dis&mode=1" OR "/index.aspx?sec=fred&pag=dis&mode=1"

IS there a function where I can pass in either string (assuming I'm on sitename.company.com) and get back an array with:

(0): sitename.company.com
(1): index.aspx
(2): sec=fred&pag=dis&mode=1

(Or, alternately, three different functions that would return the three parts?)


Path not valid.



im trying to save a file, filename as current date and time.it will give an error.

any ideas.

here is my code

string datetime=DateTime.Now.ToString();

if (GridviewtoCSV("~/Admin/doc/Reports/" + batchid.ToString() + datetime + ".csv", transactiongrid) && GridviewtoPDF("~/Admin/doc/Reports/" + batchid.ToString() + datetime + ".pdf", transactiongrid))

Scale Out: Distributed Caching On The Path To Scalability


Developers frequently face issues related to scalability bottlenecks when they have applications that need to handle a lot of load. This article describes the role of a distributed cache in building scalable applications.

Iqbal Khan

MSDN Magazine July 2009

Foundations: Render Text On A Path With WPF


With Windows Presentation Foundation (WPF) you can lay out text on a path, then animate the individual points defining the path and watch the characters bounce around in response.

Charles Petzold

MSDN Magazine December 2008

asp.net path issue


Hi all,
I am working on an application where many hyperlinks ( <a hrefs> like <a href=/web/index.html ) are used. The website is working fine on live server. The previous link goes to wwww.mysite.com/web/index.html which fine. But when i setup the website on my local machine. The above link goes to
http://localhost/web/index.html which is not correct path and I get resource not found error. If i correct the path in browser like this :

Path 'OPTIONS' is forbidden

Don't know exactly where this goes, so I shall post here.

I'm getting an error when I link to a Word Document.  My Hyperlink control simply opens up the doc in a new window.  The error message is "Path to 'OPTIONS' is forbidden."

The Word document actually comes up and is displayed, but my error handling sends me about 5 emails each time a document is viewed.  I'm using MS Application Blocks, and this is the error I'm getting:

1) Exception Information


Exception Type: System.Web.HttpException

ErrorCode: -2147467259

Message: Path 'OPTIONS' is forbidden.

Data: System.Collections.ListDictionaryInternal

TargetSite: Void ProcessRequest(System.Web.HttpContext)

HelpLink: NULL

Source: System.Web

StackTrace Information


at System.Web.HttpMethodNotAllowedHandler.ProcessRequest(HttpContext context)

at System.Web.Http

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend