Dev vs Production environments ASP.NET
-
I am working on my first ASP.NET web application in a business environment and I am trying to figure out a better way to move code between the development site (a virtual directory) where the root directory is AName/.... to the web site where aName is the web site name. Right now if I have an image in a folder path /AName/images/something.gif is the path for the virtual directory site in developoment. When we move to our web site the path would be /images/something.gif. When I am getting ready to move th ecode, I do a global find an dreplace on /AName/ then build, move the dll's and apsx, etc files to a install folder, then do a global replace back on "/ changin git back to "/AName/. Pretty hokey, huh? There has got to be a better way. Thanks, TF Tim Featherston www.QBSix.com
-
I am working on my first ASP.NET web application in a business environment and I am trying to figure out a better way to move code between the development site (a virtual directory) where the root directory is AName/.... to the web site where aName is the web site name. Right now if I have an image in a folder path /AName/images/something.gif is the path for the virtual directory site in developoment. When we move to our web site the path would be /images/something.gif. When I am getting ready to move th ecode, I do a global find an dreplace on /AName/ then build, move the dll's and apsx, etc files to a install folder, then do a global replace back on "/ changin git back to "/AName/. Pretty hokey, huh? There has got to be a better way. Thanks, TF Tim Featherston www.QBSix.com
Hi Tim. If it were me, I would reference things like images using relative references... "images/something.gif" rather than "/AName/images/something.gif". I think you can also use "~/images/something.gif" (I'm not sure about this, but I think the tilde represents the root directory of the web application provided it's setup as a virtual directory through IIS manager... someone correct me on this if I'm wrong please).
-
Hi Tim. If it were me, I would reference things like images using relative references... "images/something.gif" rather than "/AName/images/something.gif". I think you can also use "~/images/something.gif" (I'm not sure about this, but I think the tilde represents the root directory of the web application provided it's setup as a virtual directory through IIS manager... someone correct me on this if I'm wrong please).
Thanks Mike for the quick reply. I am probably not expressign myself correctly. My dev site is in a virtual directory named cardss. The production site is CARDSS. The site folder structure looks like this: Virtual Dir Web Site cardss/Images /Images cardss/Operations /Operations If a web page in the Operations folder: cardss/Operations/page.aspx has a reference to something in the images folder, /cardss/images/a.gif would be the path in the dev environment, /images/a.gif on the web site. The tilde does represent root directory on for code running on server side but it translates to ../ and we can't use ../ because of security issues. I assume everyone develops ASP.NET in virtual directories? When you move code to the production website, how do you deal with the fact that the virtual directory root (cardss) doesn't exist at the web site? TF Tim Featherston www.QBSix.com
-
Thanks Mike for the quick reply. I am probably not expressign myself correctly. My dev site is in a virtual directory named cardss. The production site is CARDSS. The site folder structure looks like this: Virtual Dir Web Site cardss/Images /Images cardss/Operations /Operations If a web page in the Operations folder: cardss/Operations/page.aspx has a reference to something in the images folder, /cardss/images/a.gif would be the path in the dev environment, /images/a.gif on the web site. The tilde does represent root directory on for code running on server side but it translates to ../ and we can't use ../ because of security issues. I assume everyone develops ASP.NET in virtual directories? When you move code to the production website, how do you deal with the fact that the virtual directory root (cardss) doesn't exist at the web site? TF Tim Featherston www.QBSix.com
Hi Tim. Why not set the directory cardss as the root for your Virtual Directory on the development box? Then a simple copy to the production is all you'll need.
-
Hi Tim. Why not set the directory cardss as the root for your Virtual Directory on the development box? Then a simple copy to the production is all you'll need.
You mean the add the cards directory to the production Server? https://CARDSS/cardss/default.aspx ?? I guess that would do it, eh? It just doesn't seem right! Now the dev tool dictates how you organize your web site? We even tried to pick up a variable from the web.config (appsetting section) where we would set a value either "/" or "/Cardss/" but some tags don't accept a variable for the path. TF Tim Featherston www.QBSix.com
-
You mean the add the cards directory to the production Server? https://CARDSS/cardss/default.aspx ?? I guess that would do it, eh? It just doesn't seem right! Now the dev tool dictates how you organize your web site? We even tried to pick up a variable from the web.config (appsetting section) where we would set a value either "/" or "/Cardss/" but some tags don't accept a variable for the path. TF Tim Featherston www.QBSix.com
Hi Tim. No, actually I meant on the development server, make sure the "cardss" directory is the root of the virtual directory for that web application.
-
Hi Tim. No, actually I meant on the development server, make sure the "cardss" directory is the root of the virtual directory for that web application.
I think it is. Currently the folder is: inetpub/wwwroot/cardss Tim Featherston www.QBSix.com
-
I think it is. Currently the folder is: inetpub/wwwroot/cardss Tim Featherston www.QBSix.com
Hi Tim. Okay, I see what you mean. I still think that the organization of your development "cardss" directory could be set up to mirror your production webroot directory in a way that you wouldn't have to change code, provided you are using relative references... it would mean using syntax like "..\images\myImage.gif" to indicate the "images" folder is the parent to the current folder. If that's not a possibility for you, I found a couple of alternatives that you may want to try. The tilde character does appear to be translated by ASP.NET as the virtual root of the web application, so provided you add "runat='server'" to your <img> tags, this might work for you:
<img src="~/Images/myImage.gif" runat="server">
I read another alternative on the web that used an ASP.NET binding expression syntax to accomplish about the same thing:
<img src="<%=Request.ApplicationPath%>/Images/myImage.gif">
Let me know if any of these suggestions help. I'm really curious now about how you decide to resolve this one.