.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

Relative path - different project

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

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?

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

path relative


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

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

Start project from view => full view path appended to the URL => 404



If I start the project while in a view, it appends that view name (and path) to the URL, and I get a 404 error.


If I then switch to any non-view, like the controller and hit F5, it starts up with no additional URL and gets routed to the default controller.


 Is there a way to fix this? Is it an option (to not pass the view url on debug), or a routing cfg issue? I'm no MVC expert.

routes.MapRoute(	"Default", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = "" } );

Thank you 

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?

Project Example: ASP.NET MVC + SubSonic Architecture

use of SubSonic to provide the DAL in association with some ASP.NET MVC sites and was waylaid in my original intent to throw up a post summarizing the architecture we're using for the effort. Well I've finally gotten around to it. Recall that in his fake it till you need it post, Dave provided a window on our architecture that I'll build upon here

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

VS2010 Professional .NET 4.0 Remote Debugging ASP Website Project


Trying to remote debug ASP website from VS2010 Pro to Windows Server 2003 machine.  Specifically, trying to debug a Web Service, but breakpoint says, "The breakpoint will not currently be hit. No symbols have been loaded for this document."  This happens for all compiled code though.  I have read this is due to missing PDB files and the work around is to manually copy them, as noted here.  Problem is, I cannot find any PDB files for my project, except referenced libraries, which I can remote debug.


  • web.config has <compilation debug="true">
  • Debugger is attached to wewp.exe process on remote server
  • Installed VS2010 remote debugger from DVD (as I can remote debug referenced libraries)

This is beyond frustrating.  I migrated my code from VS2008 .Net3.5 to VS2010 .Net4.0 to take advantage of the inherent multithreading framework.  Debugging works when using local host and was stable until deployment to test server.

Thanks in advance,


How can I be sure that my entire project is up-to-date and free of errors in VS2010?


Seems like a stupid question, but I will go to Build > Build Solution many many times and the build will succeed many many times, then I will put in a minor syntax error and the build will fail, BUT the build will not fail because of the minor syntax error; it will fail because of an unresolved type that I put in about twenty compiles ago. And then I will fix the minor syntax eror, and the compiler will still complain about the unresolved type. Here is my code:

<%@ Register TagPrefix="FTB" Namespace="FreeTextBoxControls" Assembly="FreeTextBox" %>
  <form runat="server">
  Hello World!!  

Pretty simple, really. I go to Buld > Build WebApplication1 and it runs OK. Now, if I put in a minor syntax error, such as substitute "forrrrrrrm" for "form" and then try to Build Solution, it complains not about the misspelled word, but about the FreeTextBox. And then if I correct the misspelled wird, it still complains about the FreeTextBox. Which leads me to believe that Building the Solution does not check absolutely 100% everything that needs to be checked. Is there a more thorough way of compiling a program that I need to use?

is it possible to convert whole visual studio 2008 web site project to visual studio 2010 web site p


is it possible to convert whole visual studio 2008 web site project to visual studio 2010 web site project


my current project references




i have a very annoying iis problem

iis server stops working until app pool is recycled


i am hoping that new visual studio (net framework 4.0) may solve this very annoying unsolveable problem


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.

Business Intelligence Reports Project in Visual studio 2008 ?



I wonder how to add a project template called  Intelligence Reports, something like that, to Visual studio 2008. I have SQL 2008 installed. Do I need to install some updates to get Intelligence Reports template to Visual studio 2008 ?

Thank you..

Solution/project structure


Hello, I am working in a aspx web application that must be built in several separate "modules" with different functionality which will be partly developed by different teams.

However, I need the completed app to reside in ONE virtual directory. There will be a single startup page. I need session state to be preserved across pages in different modules.

I structured it as one solution with different Web Projects and one class library project with common functionalities.


1) is this the right approach to do this? Or which one would be better?

2) each time I add a new web project to the solution, a new web.config gets created. What do I do and where do I put them?

VS 2010 + framework 4.0 + TFS

Regarding TFS and source control, I have a single Team project, the solution and web projects are inside it.



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)


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