.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

Virtual Path Problem

Posted By:      Posted Date: August 21, 2010    Points: 0   Category :ASP.Net

 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

View Complete Post

More Related Resource Links

The Path problem?

I hope to get the following result, how can I write code? Thanks!                 Source                                                                                      Target1. http://localhost:1131/Mysite/Member/MyProject.aspx     =>       /Member/MyProject.aspx2. http://localhost:1131/Mysite/MyProject.aspx                   =>       /MyProject.aspx3. http://localhost:1131/Mysite/MyProject.aspx?Type=2     =>       /MyProject.aspx?Type=2 4. http://www.Mysite.com/Member/MyProject.aspx             =>       /Member/MyProject.aspx5. http://www.Mysite.com/MyProject.aspx   &nb

Map a network share to a virtual directory path @ runtime

Hi Guys Have run into an interesting issue. We have an asp.net web application - we can deploy it over the internet, the secure intranet, local offline user laptops. On of the teams in our organization has a product by which they develop static html reports from the main database. Originally we developed a module in our app which is nothing more than an iframe. Since the html files were pushed under our application virtual directory we used to use java script to set the source of iframe to http://server/app/module/fileXXX.html   Now due to some deployment procedure changes and some security issues the html reports will be deployed on another network server and exposed through a share. Also the share will not have IIS so not virtual directory. So we can no longer set the iframe source through java script to a web file.   Is there any way i can @ runtime map a folder in my application virtual to the network share so that we can browse to these web files like before (Copying the files over from the share to my Virtual Directory is not a very elegant soln.)   Thanks Regards Siddharth

Problem in Path translation

Hi,I am developing a very basic application in C# and Asp.Net using New Website-->Asp.Net web site.This is a simple login control application available in Visual Studio.  After starting a project, I found folder structure like that Project name "WebSite2" under which I have  folders like "Account", "Scripts" and "Styles" and few files like "About.aspx", "Default.aspx" and "Web.config" under the same "WebSite2" folder. Under "Account" folder I have files like "ChangePassword.aspx","ChangePasswordSuccess.aspx","Login.aspx","Register.aspx" and "Web.config". Now I have add a simple page "ThankYou.aspx" under "Account" folder and "Thanks" under "WebSite2" folder. I have modified "Register.aspx.cs" file so that whenever a new user will register, an email will be sent to the persons inbox and from where he will activate his account and this functionality is working fine. Now the problem is that whenever a new user registered, an email will be send to him and simultaneously he will be landed to "ThankYou.aspx" page, but here the user is redirecting to "Login.aspx" page. i have tried it with so many combinations but always getting "Login.

file path problem


in the application, I need write a jpg file to local folder on server, then show it in browser.

so, the code likes show this file:

HttpContext.Current.Request.Url.Host + "/View/ViewJpg.aspx"

In the ViewJpg.aspx, it will process the jpg. /view is in root folder.

it works fine when the code is on a server, however, I have problem when I debug in on local machine.

because the code is actually http://localhost/mYproject but HttpContext.Current.Request.Url.Host only returns http://localhost.

what's the best way to deal with this?


FileUpload path problem


I have not been able to uplaod a file to my web page although the code I am using works if I copy it locally. Perhaps I am missing something in the path or I need to change some security setting on the web page?

   protected void btnUpload_Click(object sender, EventArgs e)
        SelectedFileName.InnerHtml = txtFileField.PostedFile.FileName;
        FileType.InnerHtml = txtFileField.PostedFile.ContentType;

        // convert bytes to Kbytes
        int size = txtFileField.PostedFile.ContentLength / 1024;
        FileSize.InnerHtml = (size.ToString() + " KB");
        uploadDetails.Visible = true;

        string strFileName = txtFileField.PostedFile.FileName;
        string c = Path.GetFileName(strFileName);

            // not sure if this path is correct. not working anyway
            txtFileField.PostedFile.SaveAs("~/" + c); 
            feedBack.InnerHtml = "File uploaded successfully.";
        catch (Exception exp)
            string message = "File did not upload, please try again";
            feedBack.InnerHtml = message + "\n" + exp.Message.ToString();
            uploadDetails.Visible= false;
Thanks for any help.

The virtual path '/_catalogs/masterpage/v4.master' maps to another application, which is not allow



i am creating my asp.net solution on the sharepoint(asp.net website)

(i using sharepoint2010-s1 and visual studio2010 and .net3.5)

 i using the code 'this.MasterPageFile=_myTeamSite.MasterUrl'(_myTeamSite is instance of spweb)

when test the code,this point i recieved error:

The virtual path '/_catalogs/masterpage/v4.master' maps to another application, which is not allowed.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: The virtual path '/_catalogs/ma

Virtual path provider to have custom path tokens in master page references


I managed to port Asp.net MVC to run in a Sharepoint site (only inside a particular folder not everywhere) by:

  1. Writing an IHttpModule that I use to register routes, areas, view engine and virtual path provider inside the Init method, that is called only once per application life hence it works like an application_start event
  2. Writing a custom URL routing module that only performs routing for a particular subfolder path, all other paths are ignored, so everything else works just as it does and is completely handled by sharepoint
  3. Writing a custom view engine that defines different view/master paths related to the subfolder where MVC is running
  4. Writing a costom virtual path provider that should allow me to reference masterpages based on my configured subfolder where MVC is running.
  5. Adding a virtual folder (without assigning it an application) to my Sharepoint's site, so my app will be running as part of Sharepoint site and not as a separate application
  6. Customizing Sharepoint site's config to add my MVC application's configuration, adding MVC assemblies to compilation section, adding namespaces to <pages> element so I my view will see Html helpers, and adding two modules (my intialization module that registers routes etc) and subfolder routing module.

But I would like to accomplich

Info Path Form Problem; the form is closed


Hi All

I am facing an error in info path form web enabled.


When i open a new form, it opens and saved. Even the sendingemail is also working.

But when i try to open the already saved form. The form is not opening it is displaying the error that the form has been closed. Or it is not getting the form from the location..

Problem in content deployment path job



I have created a Content Deployment path to copy data from source server to destination server.

And also i have created a job to run this content deployment path.

I made the job to run .But the job status is "PREPARING"  for a while.No change for a long time.

I dont know what might be the cause.

Could anyone help on this please?

problem in writing Element Path in Webservices has datsource for SSRS report



I have a requirement to create a webservice which returns dataset, once dataset is consumed by client application(here client app is SSRS report), I need to show dataset 's table value in SSRS rdl report.

When i see XML structure returned to client look like this

<?xml version="1.0" encoding="utf-8" ?>
<DataSet xmlns="http://tempuri.org/">
 <xs:schema id="Results" xmlns=""  
  <xs:element name="Results" msdata:IsDataSet="true"  
msdata:UseCurrentLocale="true" msprop:QueryTerms="Cool Bikes;"  
msprop:IgnoredNoiseWords="" msprop:Keyword="" msprop:ElapsedTime="938"  
msprop:Definition="" msprop:SpellingSuggestion="">
    <xs:choice minOccurs="0" maxOccurs="unbounded">
     <xs:element name="RelevantResults"

Path Too Long Problem. Accessing filenames longer than 260 chars using unicode and kernel32.dll.

I found this article a few weeks ago that provided a way to access files and folders past the 260 char length:


I put the code from "Finding Files and Folders" in a dll and wrote an app in vb accessing these functions.  However, the code randomly breaks on a specific kernel32 function call. 

I noticed that if the search finds a file (not folder) longer than 12 to 14 characters then it breaks on occasion.  This is strange because I would think it would either never break or always break.

Here's the line where it breaks:

// find next

found = FindNextFile(findHandle, out findData);

Any ideas?


Virtual Path help!!!




Im using the following code to list the contents of a folder in a data grid :

Dim dirInfo_perf_reports As New DirectoryInfo(Server.MapPath("~/published/"))
               perf_reports.DataSource = dirInfo_perf_reports.GetFiles("*.*")

This is working fine.  But now I need to list the contents of a folder outside of my root (although on the same server).

Can anyone help??

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.

info path problem on another web front end




I have a info path form which is working fine in environment (1 Web Front End and 1 Application Server). But now i have added a new web front end. Now the same form is if open through new Web Front End, it is not opening. I change the dll file but still it is giving the same error.


Can any body tell me what configuration is needed for this about info path form?

gettting exception when uploading a file using IE 6??? not a valid virtual path




I have a file upload control and just in IE 6 I get the following error when I try to upload a file. My code is further below.


 Exception Details: System.Web.HttpException: '/Members/path//C:\Users\Public\Pictures\Photos\Sample Album\Pensive Parakeet.jpg' is not a valid virtual path


MembershipUser newUser =


        HttpFileCollection uploadedFiles = Request.Files;

        for (int i = 0; i < uploadedFiles.Count; i++)


            HttpPostedFile file = uploadedFiles[i];
            string fileExt = Path.GetExtension(file.FileName).ToLower();
            string fileName = Path.GetF

'c:\test.xml' is not a valid virtual path.


Hi all,

I had problem when I run the following code

It stated that 'test.xml' is not a valid virtual path. I had check that physically the file does exists.

The program will stop at the Server.MapPath.

Please help.




objdata = new DataSet();

try {



objdata.Tables[txtProdID.Text].DefaultView.RowFilter =

"prodid='" + x1 + "'";

if (objdata.Tables[txtProdID.Text].DefaultView.Count>0)









catch (

virtual path was expected


  i am tring to upload images in the folder ,that folder creating dynamically with in the folder creating subfolders then

   i facing with error name virtual path was expected . Here is my code

        if (!Directory.Exists(Server.MapPath("~/galleries/" + foldername)))
                       Directory.CreateDirectory(Server.MapPath("~/galleries/" + foldername));

                        if (!Directory.Exists(Server.MapPath("~/galleries/" + foldername + "/" + AlbumName)))

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