Question

I have a around 15 websites on a server, i have built a tool which is common across all the sites.

Now instead of keeping the same files inside individual site's folder, i decided to keep the folder common, and keep it outside the website's folder, so that i don't have to keep the files under all the sites.

But my problem is if the folder is outside the website's root folder, i am unable to access it, as Server.MapPath does not works.

I even tried to keep those files under a folder in one of the site's root, and access them like http://domain.com/folder/control.ascx but that too does not works. it throws error saying :http:/domain.com/folder/control.ascx' is not a valid virtual path

Can anyone help me about how could i access the files outside the root folder, or keeping it inside one the site's root folder.

Was it helpful?

Solution

Have you tried adding a virtual directory under your site that points to the common directory?

Server
  Sites
    Common - base directory is C:\sites\common\
    SiteA - base directory is C:\sites\siteA\
      common - virtual directory pointing to C:\sites\common
    SiteB - base directory is C:\sites\siteB\
      common - virtual directory pointing to C:\sites\common

OTHER TIPS

You need to set the Trust Level of your whole site to Full Trust

Just open the IIS Manager, click on the root node and double click on NET Trust Levels. Here you can experiment with various Trust levels to see if your Server.MapPath allows cross site paths

Here an article with details on how to do it also with a command line

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top