Solved

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

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

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…
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

760 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

21 Experts available now in Live!

Get 1:1 Help Now