?
Solved

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

Posted on 2013-02-06
4
Medium Priority
?
271 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 2000 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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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 …
Find out what you should include to make the best professional email signature for your organization.
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

719 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