what about aspx files in web root, if projects always published in directories?

B

Bennett Haselton

If you create a ASP.Net Web application in Visual Studio .Net, you
apparently have to specify the target as a directory on a web server,
e.g. www.hostname.com/dirname, with "dirname" being the name of the
locally created project. I can't find a way to create an .aspx file
and publish it straight to the Web root directory in VS .Net.

And yet of course there are many sites with .aspx files located in the
Web root directory. Does that usually mean the authors edited the
..aspx files in VS .Net but saved them statically and uploaded them via
regular FTP to the root directory? Or that they have configured IIS
so that the root directory is aliased to the sub-directory where the
project lives? Usually this is a sign that I'm fundamentally looking
at something the wrong way; did I do it again?

-Bennett
 
G

George

In my development i am trying to use '~' sign whenever is possible.
As you probably know that ~ sign replaces the path to the Application Folder.
Example:
Response.Redirect("/dirname/my.aspx") --- wrong
Response.Redirect("~/my.aspx") --- correct.

Obviously the ~ approach only works when the URL is interpreted by ASP.NET engine.
If you have in your HTML <img src="~/my.asp"> It will stay that way and will not work.


So for those cases I have a small application "replacer" which runs through folder/subfolders and replaces the phrase1 --> phrase2


George
My Site - Body Jewelry
If you create a ASP.Net Web application in Visual Studio .Net, you
apparently have to specify the target as a directory on a web server,
e.g. www.hostname.com/dirname, with "dirname" being the name of the
locally created project. I can't find a way to create an .aspx file
and publish it straight to the Web root directory in VS .Net.

And yet of course there are many sites with .aspx files located in the
Web root directory. Does that usually mean the authors edited the
.aspx files in VS .Net but saved them statically and uploaded them via
regular FTP to the root directory? Or that they have configured IIS
so that the root directory is aliased to the sub-directory where the
project lives? Usually this is a sign that I'm fundamentally looking
at something the wrong way; did I do it again?

-Bennett
 
J

John Saunders

In my development i am trying to use '~' sign whenever is possible.
As you probably know that ~ sign replaces the path to the Application Folder.
Example:
Response.Redirect("/dirname/my.aspx") --- wrong
Response.Redirect("~/my.aspx") --- correct.

Obviously the ~ approach only works when the URL is interpreted by ASP.NET engine.
If you have in your HTML <img src="~/my.asp"> It will stay that way and will not work.
You can change the above to <img runat="server" src="~/my.gif"> and it will work.
 
K

Kyril Magnos

Hi Bennett,

Yup, you did it again. ;)

You can create a project in the root of a website. When creating the
project, just use the url of your site without a sub folder:

http://localhost will create a project in the root of your website. Of
course, if there is already a project defined there, VS.NET will bark at you
about it. :)

--
HTH

Kyril Magnos

Question of the day:
What is Mono?
A) Disease where the lymph nodes become swollen.
B) A single sound
C) A synonym for one
D) A port of .NET meant to royally irritate MSFT
E) All of the above.

| If you create a ASP.Net Web application in Visual Studio .Net, you
| apparently have to specify the target as a directory on a web server,
| e.g. www.hostname.com/dirname, with "dirname" being the name of the
| locally created project. I can't find a way to create an .aspx file
| and publish it straight to the Web root directory in VS .Net.
|
| And yet of course there are many sites with .aspx files located in the
| Web root directory. Does that usually mean the authors edited the
| .aspx files in VS .Net but saved them statically and uploaded them via
| regular FTP to the root directory? Or that they have configured IIS
| so that the root directory is aliased to the sub-directory where the
| project lives? Usually this is a sign that I'm fundamentally looking
| at something the wrong way; did I do it again?
|
| -Bennett
 
G

George

<img runat="server" src="~/my.gif"> for every image on a page is a big waist.

Do not come back saying that ASP.NET is slow.


George
My Site - Body Jewelry
In my development i am trying to use '~' sign whenever is possible.
As you probably know that ~ sign replaces the path to the Application Folder.
Example:
Response.Redirect("/dirname/my.aspx") --- wrong
Response.Redirect("~/my.aspx") --- correct.

Obviously the ~ approach only works when the URL is interpreted by ASP.NET engine.
If you have in your HTML <img src="~/my.asp"> It will stay that way and will not work.
You can change the above to <img runat="server" src="~/my.gif"> and it will work.
 
J

John Saunders

<img runat="server" src="~/my.gif"> for every image on a page is a big waist.

Do not come back saying that ASP.NET is slow.
Of course, you know this by measurement?

Recall that pages are compiled. The translation from "~/my.gif" to http://www.site.com/my.gif will occur once.
--
John Saunders
johnwsaundersiii at hotmail


George
My Site - Body Jewelry
In my development i am trying to use '~' sign whenever is possible.
As you probably know that ~ sign replaces the path to the Application Folder.
Example:
Response.Redirect("/dirname/my.aspx") --- wrong
Response.Redirect("~/my.aspx") --- correct.

Obviously the ~ approach only works when the URL is interpreted by ASP.NET engine.
If you have in your HTML <img src="~/my.asp"> It will stay that way and will not work.
You can change the above to <img runat="server" src="~/my.gif"> and it will work.
 
J

John Saunders

Kyril Magnos said:
Hi Bennett,

Yup, you did it again. ;)

You can create a project in the root of a website. When creating the
project, just use the url of your site without a sub folder:

http://localhost will create a project in the root of your website. Of
course, if there is already a project defined there, VS.NET will bark at you
about it. :)

You will also have problems if you're using a source control system and you
have other developers working on the same project. They will _all_ have to
use http://localhost as the location for the web site. That's yet another
reason to use http://localhost/project.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top