ASP.Net Host

Development/Programming

Q.) How do I use code to find the correct file path for my images (or other) folder using C#?
C# sample:

A.) Use the "Server.MapPath" function:

C# sample
string path = Server.MapPath(@"~/Images/");

That will return the path of the "Images" folder under the root of your website.

Q.) How do I get a file path using vbscript?

<%string path = server.MapPath(".")%>

This returns the name fo the folder that the page is in.

Q.) ASP.Net validators are posting back to the server without doing the client-side validation. It works properly on my computer, but not when I move it to Aquest Hosting's server.

Your code is looking to the root of your website for a folder called "/aspnet_client/system_web/1_1_4322/WebUIValidation.js". Since it isnt there, it goes on and does the post back.

Please copy and upload the folder "c:/inetpub/wwwroot/aspnet_client" from your computer to the root folder of your website on our server.

Q.) IE Web Controls aren't working. The work fine on my computer, but not when I upload to the Aquest server.

Your code is looking to the root of your website for a folder called "/webctrl_client/...". It works fine on your computer because the root of your site on your computer is C:\inetpub\wwwroot\, and the folder exists. On our server, the root of your site is your domain folder.

Please copy and upload the folder "c:/inetpub/wwwroot/webctrl_client" from your computer to the root folder of your website on our server.

Q.) I'm using vbscript and getting an error when trying to do Server.mappath("../myfolder/myfile.htm").

The error you are getting is becuase we have Parent Paths disabled, so you cannot use the "../" to move backwards (up) your folders. Please try this: Server.MapPath("/myFolder/myfile.htm")

The above line begins at the root of your domain, and moves down to your folder. This method has the added benefit that you can move your script page to another folder, and it will still work, as long as you don't move "/myfolder/myfile.htm" because it will always start at the root instead of being dependent on the location of the script file.

0 Comments

We recommend Aquest Hosting for your ASP.Net 2.0 hosting, Community Server hosting, and DotNetNuke hosting.