Tracking Forums, Newsgroups, Maling Lists
Home Submit Tracker Forums
  Advanced Search


C# - Getting Project Root Path In Controller .NET MVC?

I am using dotlesscss for my css and I remember how to use that but what I am forgetting is how to get the root project path so that I can generate the full file path to my .less file to get for the less engine to parse. How do I get the project root path so that I can generate the path for my less files?

View 1 Replies (Posted: Mar 5 at 12:58)

Sponsored Links:

Related Forum Messages For ASP.NET category:
Add The Image To Another Project's Root Folder Without Setting The Direct Path?
In my website I allow user to upload the images. The images are suppose to be uploaded into 2 folders. One folder located in the root the other in another projects root. Currently I'm using the following code to do this.


How can I add the image to another project's root folder without setting the direct path?

Posted: Sep 11, 2009 03:21 AM

View 12 Replies!   View Related
MVC :: Get Root Application Path?
A simple question for you guys but I just cant figure it out today.

How can I get the root path for the application from a view with current path looking like this?


I tried HttpContext.Current.Server.MapPath("~") but that gives the physical path.

Posted: Jul 21, 2009 05:28 AM

View 2 Replies!   View Related
How To Specify Root Path In Simple HTML
i need to reference an image starting from the root, however i cannot use the ~ root operator since it is a normal <img> and not a server control.

how can i specify root path in simple HTML so that i can access the image from all three folders (see example below):


i need to reference a picture in images folder from mypage.aspx, kb0000a.htm and from a00001.htm

<img src="~/images/picture.jpg"> is not working as it is not a server image; i cannot use the server object.

Posted: Dec 18, 2009 01:56 AM

View 3 Replies!   View Related
Configuration :: Why Is The Directory Only Seen When Outside The Root Path
I'm trying to deploy my web project to my local IIS server (C:inetpubwwwrootlunchbox). By default the in is created inside the project directory - i.e lunchboxin. This setup, however, gives me the following error when I try to open the site:

When I move the in directory outside the project root (i.e C:inetpubwwwrootin), the site opens up just fine. I'm also able to test the web project from Visual Studio without any issues.

Can someone tell me why I have to move the in directory outside the project root to make the site work? What can I do to not have to do this?

Posted: Dec 02, 2010 08:27 PM

View 4 Replies!   View Related
How To Access Root Directory Path
How to access hosting root directory (e.g. which contain "www" directory, where visible to users files are kept).

Request.PhysicalApplicationPath(), Server.MapPath("~"), Server.MapPath("../") methods give a string with "/www" in the end

Server.MapPath("../../") give "Cannot use a leading .. to exit above the top directory" error Is there any way to get root directory path ?

Posted: Dec 26, 2008 05:47 PM

View 4 Replies!   View Related
Taking Path From Application Root In JavaScript?

I have write a javascript function loadPage(), that needs a path to some page as a parameter. I need to give this path from the application root. I dont want a relative path.

Posted: Sep 7 10 at 4:51

View 2 Replies!   View Related
C# - File.Exists Using The Wrong Root Path?
In my c# class I wrote I have a photo property that returns the photo source if the image exists (nothing or default image otherwise). In my code I use:

public string Photo
string source = "~/images/recipes/" + id + ".jpg";
if (File.Exists(source))
return "~/images/recipes/" + id + ".jpg";.......

If I get the FileInfo() information for this image I see that I tries to find this image in the following directory: C:Program Files (x86)Common FilesMicrosoft SharedDevServer10.0~images ecipes Of course the image is not located in that directory and File.Exists is returning me the wrong can I fix this?

Posted: Mar 17 at 19:55

View 3 Replies!   View Related
Web Forms :: Find The Root Path Of Website?
I want to find the root path of my website.

Im using Request.PhysicalApplicationPath right now which looks like this:

F:CasperMy DropboxDotNetPortfolioV2 (Which is good)

But if I go to a folder it will be:

F:CasperMy DropboxDotNetPortfolioV2FolderName (Not good)

I just want the root.

Posted: Jan 03, 2010 10:53 AM

View 2 Replies!   View Related
C# - How To Pass The Data Path For Object Flash Tag From The Root Directory
I'm using urlrewriting to rewrite my url. Let me introduce my problem by bellow example: Here is old url: http://localhost/test/pages.aspx?pageid=1 I have 2 cases to rewrite:


The first case is ok, but I would like to use the second case. In this case I must use root path for image, css and object tag (for flash):

With image, I modified to: <image src="~/images/icon.jpg" runat="server"/>
With css, I modified in head tag: <head runat="server">

But with the object tag, I don't know how to set root for the data, movie parameter:

<object data="anim/head.swf?xmlPath=./menu_flash.html" type="application/x-shockwave-flash" width="962" height="228">
<param name="movie" value="anim/head.swf" />
<param name="quality" value="high" />

Posted: Sep 21 10 at 4:42

View 2 Replies!   View Related
Custom Server Controls :: Make Root Relative Path?
I'm creating a custom server control which needs totake in a root-relative path for one of it's properties. I use the UrlProperty, but when I select a file in the markup, the selected path doesn't inlcude the the "~/". I'd like to mimic the behavior of a hyperlink. So let's say I have this:

<asp:HyperLink ID="HyperLink1" NavigateUrl

When I type in an equals sign after the NavigateUrl property, intellisense pops open a URL picker and I can pick from any page to produce this code:

<asp:HyperLink ID="HyperLink1" NavigateUrl="~/default.aspx"

this code has the "~/" in front. When I use my control, I have this:

<cc1:TestControl ID="TestControl1" Url="default.aspx"

the C# code has this property:

public string Url{ get; set; }

Does anyone know how I can make the "~/" be placed in front to make a root-relative path?

Posted: Jul 26, 2010 06:01 PM

View 3 Replies!   View Related
Default Project Path / Get Path For That File?
I have created window service project in that i have i have to access that file in project,so how can i get path for that file.

Posted: Apr 27, 2009 11:47 AM

View 3 Replies!   View Related
Web Forms :: NavigationURL Is Referring To The Correct Path Whether Aspx In Root Or In Sub Folder?
I have a main_menu.ascx web control placed in my root and contains my website navigation menu with NavigationURL to the pages

I have my root files and I included the ascx file there Until here, I have no issueNow!

I have sub folders in my root and I want to include same ascx file because I don't want more than one main_menu file!

But the problem here is with the NavigationURL because it will be different when the aspx file is in sub folder

How can make sure my NavigationURL is referring to the correct path whether aspx in root or in sub folder?

Posted: Sep 29, 2010 02:17 PM

View 1 Replies!   View Related
Web Forms :: Master Pages Vs. Root Calling Images Absolute Path?
I have a MasterPage that is referenced on amajority of my site. On that master page I am calling for a background image


The directory is MAIN/Home/Welcome.aspx

The image comes up fine. BUT, when I move to another page, which is in the root

The directoy is MAIN/docking.aspx

The image does NOT come up. If I change the path to a single "." like background-image: url('./images/menubar_bg.png');

it comes up just fine.

So how can I make it universal so that it always tries to find images/menubar_bg.png? no matter what folder you are in within the application?

Posted: Sep 09, 2009 01:34 PM

View 1 Replies!   View Related
Web Forms :: Path / Can See Logout One But Not 2Keys,images Folder Is Right Inside The Root?
I have two icons onthe master page for logout and change password, however I can see oneand the other one is shown with a red x and text. The following isthe markup coding:

I can see the Logout one but not the 2Keys. images folder is right inside the root.


Posted: Dec 31, 2009 04:43 AM

View 11 Replies!   View Related
How To Create The Class In The Web Root For The Project
I have a bit of code I am reusing on a lot of my pages so decided to put this code into a Class and placed this class inside the App_Code directory. However when ever I try and create an instance of tis class so that I can use it's Methods etc I can't seem to get it to work, but if I create the class in the web root for the project it all wrks as expected.

Posted: Mar 20, 2010 09:07 PM

View 12 Replies!   View Related
Can't Load Project Because Root Element Is Missing
My machine shut down because of some "unexpected error". I rebooted it in normal mode. I got an error when I tried to reload my project from the start page.

It said: "Unable to read the project file"myProject.csproj". The project file could not be loaded. The root element is missing."

Does anyone know what would have caused this or what this means? I looked in the directory that it resides in and the .sln file is there.

Posted: Nov 11, 2009 12:20 AM

View 7 Replies!   View Related
AJAX :: Can't Use Root Of Project In Aspx Page
i added a class to the root of my project and in it i havecreated anoverride for the html editor


the thing is that i can't (don't know how to)use it in my .aspx page. i tried adding a "Register Assembly..." but i didn't got it to work.

Posted: Dec 12, 2010 09:31 AM

View 5 Replies!   View Related
ImageUrl Trying To Display An Image Outside Of Project Root?
I am working with two different web sites in In the first project i upload some images to a specific folder under the project root and save just the filename in the database, now i am trying to display this images at some page of the second project I know the filename from the database and the image folder as absolute pat but I have not been able to display the image, even thought when looking in firebug the image src is correct src="D:/MyFolder/image.jpg" the image does not display, probably because it is not pointing in the right directory. I have also tried using Server.MapPath and then my D location but still no success.

Posted: Jan 5 10 at 22:23

View 3 Replies!   View Related
Web Forms :: No Default.aspx In The Root Of Website Project?
i have a website project. i have 2 folders within default.aspx. in the root i have no default.aspx.

How can i redirect users when they are in Role "Folder1" to the ../Folder1/default.aspx
and user in Role "Folder2" to the .../Folder2/default.aspx

Posted: May 27, 2010 01:36 PM

View 2 Replies!   View Related
Visual Studio :: Copy Certain Files From Other Projects To The Root Project?
I have a solution with close to 'x' projects with 1 startup project. I want to copy certain files from other projects to the root project when I run my application. I feel invoking a batch file looks to be a better option as it is easier to modify anytime.

Posted: Jun 25, 2009 12:23 AM

View 2 Replies!   View Related
Configuration :: Visual Studio Web Setup Project - Deploy Outside Of Web Root (wwwroot)?
It is possible to create a Visual Studio WebSetupProject that deploy my files outside wwwroot folder and set IIS virtualdirectoryto this folder?

Posted: Aug 02, 2010 05:25 PM

View 1 Replies!   View Related
C# - Controller Path Not Found For Static Images?
I have an image folder stored at ~/Content/Images/

I am loading these images via

<img src="/Content/Images/Image.png" />

Recently, the images aren't loading and I am getting the following errors in my error log. What's weird is that some images load fine, while others do not load.

what is wrong with my routes? Am I missing an ignore route for the /Content/ folder?

I am also getting the same error for favicon.ico and a bunch of other image files...

<Fatal> -- 3/25/2010 2:32:38 AM -- System.Web.HttpException: The controller for path '/Content/Images/box_bottom.png' could not be found or it does not implement IController.
at System.Web.Mvc.DefaultControllerFactory.GetControllerInstance(Type controllerType)
at System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName)
at System.Web.Mvc.MvcHandler.ProcessRequest(HttpContextBase httpContext)
at System.Web.Mvc.MvcHandler.ProcessRequest(HttpContext httpContext)
at System.Web.Mvc.MvcHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext httpContext)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

My current routes look like this:

"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" } // Parameter defaults
"ControllerDefault", // Route name
"{controller}/project/{projectid}/{action}/{searchid}", // URL with parameters
new { controller = "Listen", action = "Index", searchid = "" } // Parameter defaults

Posted: Mar 25 10 at 4:26

View 5 Replies!   View Related
MVC :: The Controller For Path /favicon.ico Does Not Implement IController?
I just upgraded our code base to use the Prevew 3 preview and now I am getting this exception:

System.ArgumentNullException was unhandled by user code
Message="The controller for path '/favicon.ico' could not be found or it does not implement the IController interface.
Parameter name: controllerType"


All I am trying to do is render a view where the url is /Request/New

It seems like the framework is trying to find controllers for images, a co-worker is having the same problem with another image.

Posted: Apr 25, 2008 03:52 PM

View 11 Replies!   View Related
MVC :: The Controller For Path '/' Could Not Be Found Or It Does Not Implement IController?
I am new in ASP.NET and of course in ASP.NET MVC too. I created website based on this tutorial: ttp:// after run website I have an error:
The controller for path '/' could not be found or it does not implement IController.Screen:

Posted: Jun 24, 2009 06:33 AM

View 3 Replies!   View Related
Root Path With Tilde - Doesn't Change Upper Case To Lower Case
I have my project set up with the virtual path "/MyVirtualPath", create the virtual directory in IIS 6 (W2003) and everything works fine. Then to work better with Google Analytics I change the virtual path "/myvirtualpath" and change all redicecciones and links to lowercase. also applies the class "lowercase route urls in aspnet mvc" and works perfectly.

The problem I had to modify the virtual directory in IIS, delete virtual path "/MyVirtualPath" and I created the new "/myvirtualpath", but in all cases I use tilde "~" or where I make a "RedirecToAction" (which should take "LowercaseRoute"), continues to maintain the virtual path "/MyVirtualPath". For example, if I see the HTML source code in the browser, see "/MyVirtualPath/Content/Site.css" instead of "/myvirtualpath/Content/Site.css. "

Posted: Dec 30 10 at 13:41

View 1 Replies!   View Related
ISS Virtual Directory And HTML's Reference To Root Directory Path
I have created a virtual directory FOO through IIS, which has alocal path of D:websiteFOOhtml, and thereby accessable at [URL] I have an image D:websiteFOOhtmlimagesBAR.jpg, and I want to reference this image within any HTML file within any subdirectory using the following HTML tag: <img src="???imagesBAR.jpg" alt="BAR" align="middle" border="0" />

If the aforementioned HTML codeis used, then what would I need to put within? to assure that any of the following HTML files can reference imagesBAR.jpg from root directory: D:websiteFOOhtmlSubAA.html

Posted: Dec 30, 2008 04:02 PM

View 3 Replies!   View Related
Get The Physical Controller Class File Path Of The Executing Action Method?
Assume the current executing action method is Index() in Home controller. From within Index(), how to obtain the physical file path of the Home controller? Assume we don't know the file structure until runtime.

Posted: Dec 21 10 at 15:49

View 2 Replies!   View Related
MVC :: Redirect To A Controller In A Different Project?
If I have two projects say Project 1 and project 2 can I have a controller actionin project1 redirect to a controller action in project2?

Posted: Feb 22, 2010 10:52 PM

View 1 Replies!   View Related
MVC :: How To Call A Controller From Another Referenced Project
I want to create a base web project which other projects will extend. How can i call the render action on the controller found in the base controller?

Posted: Mar 10, 2011 02:07 AM

View 1 Replies!   View Related
MVC :: Compile A Project So That I Get Different DLLs For Each Controller?
My requirement is such that we have some standard code across the MVC application and then some custom client specific code. I want to logically group the controllers so that a separate compiled DLL is created for each logical set of conrollers. Or if possible create a separate DLL for each controller. How can I achieve that?

Posted: Jun 19, 2009 02:38 PM

View 13 Replies!   View Related
Mapping Xml Path In A Web Project?
I am using a xml file to get some values.

I am reading xml like this

Dataset ds = new Dataset();


I want to know that is this a better method to read xml file or storing xml path in web.config file and then using it is a better choice.

Posted: Nov 10, 2010 05:53 AM

View 3 Replies!   View Related
C# - How To Get Referenced .dll's Path In Web Project
I have a class library that references a folder and the files in it.

I've added this library as a reference in my ASP.NET web project and I can't figure out how i'm supposed to get the path to this folder.

Or would you have to pass the Server.MapPath in from the website?

Posted: Jan 21 10 at 20:04

View 1 Replies!   View Related
Relative Path - Different Project?
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?

Posted: Sep 20, 2010 08:31 AM

View 4 Replies!   View Related
Specify Project Folder Path?
How do you specify the path to a folder in you project. I have a Documents folder in my project. How would I refer to the path ie "~Documents"; instead of on the C drive ie

StreamWriter sw = new StreamWriter("C:\Test.txt");

Posted: Mar 24, 2011 10:45 PM

View 3 Replies!   View Related
Web Forms :: ScriptManager Uses Website - Root Instead Of Application Root Directory
I ran into the following issue when trying to run a test website on IIS 7.5 (Windows Server 2008 R2 DatacenterEdition). The web-app is configured to run with framework version 3.5 in a .Net 2.0 app pool. Also the framework 4.0 beta 2 is installed on the server. The application named 'TestPfade' is locatedunder the website's rootnamed 'Default'. It is not only avirtual directory but defined as an application. The folder structure looks like this: The markup of the sole document reads as follows:


When viewed in a browser the image gets shown because the given relative path is correctly resolved to 'images/Lighthouse.jpg' but the paths to the ajax-framework resources also include the application's root folder and therefor aren't found: 'src="/TestPfade/WebResource.axd?d=1bX...' Here is the complete html-source generated:


Posted: Jan 27, 2010 02:41 PM

View 9 Replies!   View Related
Virtual Directory Root Vs Default Web Site Root
I am using iis 5.1 in which we have only only one default website, I have two projects v2 and v3 my website points to v2 projects and have some folders images, styles etc now i have a virtual directory under this website that is hosting project v3 and having the same folder hierarchy as v2 in the home page of the both projects i have img src="imagesedlogo.gif" alt="logo"/> but this shows the same image that is in the v2 directory, How can i show different images for both projects. using "" get the root of the web site but how can i get the root of virtual directory under that website

Posted: Feb 11 at 12:02

View 2 Replies!   View Related
Request The Root Default.aspx Without Specifying It In The Url For Your Root Application?
How can you request the root default.aspx without specifying it in the url for your root application?e.g. ttp://localhost/MyApp/ instead of http://localhost/MyApp/Default.aspxshould be able to do bothI'm not sure if this is a setting in IIS 7.5 for the application or what.

Posted: Sep 17 10 at 15:52

View 3 Replies!   View Related
Finding Path For Project File?
I have a project page which is referenced from another project. when i use the following code:

appPath = AppDomain.CurrentDomain.BaseDirectory


appPath = System.Environment.CurrentDirectory I get the directory of the calling project file's bin directory. What i would like to have is the directory of the page which is being referenced. This page is called from a project outside of the main running project.

Posted: Nov 10, 2008 09:31 PM

View 6 Replies!   View Related
C# - Changing Output Path In Web Project In VS2010
I have several ASP.NET web projects and their Output folder are set to "C:Builds[ProjectName]bin" (instead of the default "bin" folder). This makes "F5" Debugging not working because the ASP.NET Development Server expects the "bin" folder under the project folder.

I then changed to use Local IIS Web server (http://localhost/webproject1") and manually updated the vdir physical path to my custom output path. However the VS2010 will not load the csproj because it detects the url is already mapped to a different folder location.

I know I probably shouldn't change the Output folder. But wondering if there is an easy way to workaround this? The goal is to make "F5" debugging work with custom build Output folders.

Posted: Jan 7 at 23:13

View 2 Replies!   View Related
Copyright 2005-08, All rights reserved