Solved

How to reference web-related files above/outside the root of default.aspx

Posted on 2013-02-06
4
268 Views
Last Modified: 2013-02-10
I want to structure a variety of web apps as such:

C:\Webapps\Site1\default.aspx
C:\Webapps\Site2\default.aspx
C:\Webapps\Site3\default.aspx
etc...

Having quite a few web apps that will use common code, i want a directory within C:\Webapps\ that can be referenced by each and/or any website, instead of duplicating code all over the place.

Thus:

C:\Webapps\Common\somecommonfile.js
C:\Webapps\Common\somecommonfile.css
etc...

Contributing to the problem, I'm working on these apps on my local machine which is a windows XP and IIS6 machine with Visual Studio 2010.

After each application's completion, it will be deployed to a server (2007) with IIS7.

There could be two possible solution to 1) get this to work on my machine in a "generic reference" manner, and 2) get this to work on the web server, with as little effort as possible to change from a local-based solution, to a server-based solution.

I've read quite a few articles, but nothing concrete explaining how to do this (include/get access to the files) for the different file types in ASP.net:

* .js files
* .css files
* .aspx files

Thanks!
0
Comment
Question by:Kobz46
  • 2
  • 2
4 Comments
 
LVL 33

Assisted Solution

by:Big Monty
Big Monty earned 500 total points
ID: 38859912
why not create a virtual directory in IIS that points to C:\Webapps\Common\ and use that?
0
 

Author Comment

by:Kobz46
ID: 38867798
How would you refer to that directory in code then:

1. A savascript include -
     <script type="text/javascript" src=X/x.js></script>

2. A CSS include - <link href="X/x.css" rel="stylesheet" type="text/css" />
     
?
0
 
LVL 33

Accepted Solution

by:
Big Monty earned 500 total points
ID: 38868003
say for instance the path to your website is located in

c:\web\website1

now lets also say you have another website in

c:\web\website2

you have your common folder located in

c:\web\common

and this is where you want to have all of your shared files. so you've created virtual folders in each web application within IIS call "common".

so in your code, you would just do

<script type="text/javascript" src="/common/somefile.js"></script>

(I can't remember if you need the first slash, if it doesnt work, try removing it)
0
 

Author Comment

by:Kobz46
ID: 38874954
Works perfectly thx man!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question