Solved

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

Posted on 2013-02-06
4
262 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 32

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 32

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
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…

932 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now