Solved

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

Posted on 2013-02-06
4
270 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
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)
Suggested Courses

624 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