Custom VirtualPathProvider - Unable To Serve URLs Ending With A Directory
Jan 20, 2010
As part of a CMS, I have created a custom VirtualPathProvider which is designed to serve a single file in place of an actual file structure. I have it set up such that if a file actually exists on the server, that file will be served. If the file does not exist, the virtual content stored for that address will be served instead. This is similar to the concept of serving a website from files stored in a database, though in this case the content is stored in XML files on the server.
This setup works perfectly when a request is made to a specific page. For example, if I ask for "www.mysite.com/foobar.aspx", the content that is stored for "foobar.aspx" will be served. Further, if I ask for "www.mysite.com/subdir/foobar.aspx", the appropriate content will also be served.
The problem is this: If I ask for something like "www.mysite.com/foobar", things begin to fall apart. If the directory exists on disk (and doesn't have a configured default page in IIS, such as index.aspx), I will get a "Directory Listing Denied" error. If the directory does not exist, I'll simply get a 404 - Resource Not Found.
I've tried several things, and so far nothing I've done has made a bit of difference. It seems as though IIS is simply noting the nonexistence of a directory (or default file in an existing directory) and serving up its own error code, without ever asking my application what to do with the request. If it ever did get to the application, I would be able to solve the problem, but as it stands, I'm quite lost. Does anyone know if there is some setting in IIS that is causing this?
I've looked for every resource I can find on the subject, and am coming up empty. I know this should be possible, because I have read tutorials on serving content from both databases and ZIP files.
p.s., I am running IIS6 and .NET 3.5
View 1 Replies
Similar Messages:
Aug 30, 2010
I added the following lines to Application_Start method in global.asax:
var provider = new TestVirtualPathProvider();
HostingEnvironment.RegisterVirtualPathProvider(provider);
Yet the 'TestVirtualPathProvider' is never used when deploying this application in IIS6 (it does in the ASP.NET Development Server).
Edit: the default path provider has always done its job correctly and served (non-embedded) views correctly. The problem is simply that I want to use my own path provider to provide embedded views. So, initially, I already had the following wildcard mapping configured:
Any possible reasons why this does not work in IIS6? Are there any other factors (handlers for example) wich might influence the used VirtualPathProvider?
View 4 Replies
Oct 7, 2010
I'm trying to calculate folder size of remote server.I have credentials of server.By using WMI,I could fetch the existing Logical drives in remote server. But,couldn't get Folder name or details..Here,my folder is not shared one..I like to get WMI solution for it..if it not possible,atleast any dos commands to get file size of remote machine like this, \ServerIP:username@password\foldername -dir/s . .
View 2 Replies
Mar 31, 2010
I would like to serve a custom 404 page from ASP.NET MVC. I have the route handler and all the infrastructure set up to ensure that nonexistent routes are handled by a single action:
public ActionResult Handle404()
{
Response.StatusCode = 404;
return View("NotFound");
}
Problem: IIS serves back its own content (some predefined message) when I set Response.StatusCode to 404 before returning the content.
On the VS development web server, this works as intended - the status code of the HTTP response is 404 while my content (the NotFound view) is served.
I believe that when the IIS processing pipeline sees that the application returns 404, it simply replaces the whole response with its own.
What setting in IIS affects this behavior?
I do not have access to the IIS installation so I can not investigate this - however, I can ask the hosting provider to tweak the configuration for me if I know what exactly needs to be changed.
View 1 Replies
Oct 22, 2010
I have an application where I rewrite some URLs for a masking effect. If I run the application through VS, it works fine. However, when I try to run it through a virtual application, it says:
Could not load file or assembly 'MoonFlareStudiosLibrary.UrlRedirection' or one of its dependencies. The system cannot find the file specified.
MoonFlareStudiosLibrary.UrlRedirection is the code namespace that handles all my url redirection and rewriting.
When I say "run it through a virtual application" I mean I use IIS7 to create a virtual application in my wwwroot folder so I can just type "localhost/<app name>" to run it.
hy it work when debugging but not through the virtual application?
View 12 Replies
Aug 18, 2010
how best to allow a user to create their own URL? Say I have a domain like, www.mydomain.com, and I want the user to be able to create a custom ending to the URL like www.mydomain.com/companyname . Then when the URL is hit it will load the data for that company. Is this done via ASP.NET MVC routing? Any other ideas? I don't want to have to do any manual setup of site after user names it - like IIS changes or routing config file changes.
View 2 Replies
May 12, 2010
I have a web site built using asp.net with ugly URLs like /DisplayContent.aspx?id=789564.
I know how to migrate the database, but the Wordpress urls will be (naturally) different.
Can I simply write some mapping or do I have to include a rewrite rule for each subpage (300 pages) in .htaccess?
Should I provide a rewrite rule for each existing page that would transform a full old url to the known new url, like for example:
/DisplayContent.aspx?id=789798 -> /2010-5-10/Title-Of-The-Post
Even if I manage to migrate the URLs, the structure of the HTML for the new content will naturally be different. How does this affect SEO?
Should I run asp.net and wordpress side by side and issue the redirects from the asp.net application?
What is the most efficient solution to this kind of migration of URLs without doing PHP programming?
View 2 Replies
Nov 16, 2010
i have a function that pulls URLs from various web resources. needless to say some are full valid URLS and some are relative as per the HTML of the page. below is my asp.net/ c# logic i derived for examining the URL and then generate a full usable URL from whats pulled from the site...
NOTE:
origianlurl is the full url of the first searched page, and relativeUrl is a url found within the searched page (it can be a full www.site.com or a /contactus.html)
private string ResolveRelativePaths(string relativeUrl, string originatingUrl)
{
if (relativeUrl.StartsWith("http") || relativeUrl.StartsWith("www"))
return relativeUrl;
if (relativeUrl.StartsWith("/"))
{
//get main url something.com
[code]...
View 1 Replies
Sep 19, 2010
I am fresh in ASP.NET MVC framework. This is may be a silly question for you. Sorry about that.I have implemented a VirtualPathProvider. The VirtualPathProvider reads the view from File system.However my problem is the method GetFile(string virtualPath) is not executed every time for every request. I think it is related to the caching, isn't it? What I want is getting file every time for every request. Because for some cases, the page in the file system will be modified and users want the system shows the changes immediately.
View 1 Replies
Dec 14, 2010
I'm working trying to realize a requirement where the pages should be 'configurable' at runtime (per client), stored in a database - a requirement that I have no say in Anyway, the current plan is to use the Razor view engine and 'load' the 'pages' dynamically. I have a basic sample working using a VirtualPathProvider and VirtualFile that serves up Raz'pages' on the fly.The question I have if there is a better approach when I have the Razor 'pages' stored in a dB (or any other repository)?
There seems to be some constraints and concerns when I check other postings. For example:'If a Web site is precompiled for deployment, content provided by a VirtualPathProvider instance is not compiled, and noVirtualPathProvider instances are used by the precompiled site.'
(from http://msdn.microsoft.com/en-us/library/system.web.hosting.virtualpathprovider.aspx )
View 1 Replies
Oct 15, 2010
We got a lot of intranet websites that share the same design. Therefore we've put the master pages, stylesheet, images and javascripts in a shared assembly.
The content is loaded by using:
HostingEnvironment.RegisterVirtualPathProvider(new VirtualFilesProvider());
ViewEngines.Engines.Clear();
ViewEngines.Engines.Add(new WebFormViewEngineWithOurVirtualPathProvider());
The problem is that Visual Studio cannot find the images or masterpage and therefore gives us a lot of warnings + that we cannot select the masterpage when creating new view pages.
Note: Everything works fine when running the websites.
View 1 Replies
Aug 15, 2010
I am trying to attach my database to Microsoft SQL Server Management... I right clicked on Database -> Add and then tried to look into the directory however I cannot expand the directory and when I use the exact hyperlink [...]httpdocsApp_DataurantitDB.mdf
I get an error message of Inetpubvhost[...]httpdocsApp_Dataurantit.mdf failed with the operating system error 5(Access is denied). (Microsoft SQL Server, Error: 5133)
View 3 Replies
Jan 27, 2010
i am writing following code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
[Code]....
wen i m running this code its giving me "access id denied" exception..
View 2 Replies
Jul 15, 2015
I have created a website that my login use an active directory as an account access. In my code I specified the default Active Directory that my system will check for account validity.
However, my problem now is that if I'm using a different connection, I'm getting an error of "Connection not available". How am I going to connect to my default active directory using a different internet/network connection?.
View 4 Replies
Sep 28, 2010
I am trying to get settle with my new dev environement and when I create a new web project and try to run it on IIS instead of the virtual server and use the create Virtual Directory button I get the following error message:
Unable to create the vitual directory. To aceess local Web sites, you must install the following IIS components:
IIS6 Metabase and IIS 6 Configuration Compatibility ASP.NET
In Addition, you must run Visual Studio in the context of an administrator account.
PS: I was running VS 2010 as an administrator when I got this error
View 2 Replies
Oct 27, 2010
I have created a user control and am ready to convert it into a custom control. I am trying to follow:
[URL] the steps mentioned in the link.
I am not seeing Build / Publish Web Site option.
I am using VS 2008. I only see Publish User Control but it doesn't give all the settings mentioned below. When I do publish user control, it just copies the ascx file to the desired location. how can I convert the user control to custom control.
View 2 Replies
Nov 25, 2010
I am really stumped on this. I have IIS setup on my local box, and a virtual directory pointed to the folder MapBuilder. IUSR and IWAM have been given full access. When I run this through web developer, everything works great. When I access it through IIS, the following error is generated:
[Code]....
The line of code that generates the error is:
[Code]....
If I change the code to use a virtual directory I get the same basic error on the Overview.Save call:
[Code]....
View 2 Replies
Sep 6, 2010
IIS 6 installed on Vista (Virtual PC) not member of domain, Visual studio 2008 based website. Active Directory Membership configured in web.config.
Trust level set to Full. Using Login control to authenticate.
[Code]....
View 2 Replies
Sep 9, 2010
this is what i used:
[code]...
It throws me out saying genral access denied... finding the exact solution on how i could create a configuration page such that a certain set of groups could be assigned to my application.
View 1 Replies
May 6, 2010
I have load balanced web servers My application has a function that allows the user to upload their company logo to display in the application header obviously, when they upload the logo image file, it needs to be in a central location or otherwise, the file will not be accessible to the other server on the load balancer. in order to be able to upload the image through the application other one of either servers and then display it on both servers I need a virtual directory on both servers that point to a third "file server" (this is the "AcctData" directory shown below with a sub folder "images")
If I use pass-through authentication I get a 401 error. If I use a specific user that's set up on both boxes, I get a 500 error. I've also tried sticking a Web.config file in the "AcctData" directory allowing anonymous access.
View 1 Replies
Nov 3, 2010
I cannot get a successful connectiong to the active directory when logging onto a web form. Here is the code I have in the web.config:
<configuration>
<appSettings/>
<connectionStrings>
[code]...
View 1 Replies
Jan 27, 2011
I am very exited to find out how to do this.I have created 10 custom webusercontrols which is meant to be used on several custom sites on my website etc. and I want to find out how I can make a directory which will work the same as the asp.net.At the moment I have to register the webusercontrol at the top of the page like this:
<%@ Register TagPrefix="prefix" TagName="UserControl" Src="Source" %>
How do I create a directory that contains all of my webusercontrols, so I only have to register the assembly and can use the prefix and then the intellisense will appear?
View 1 Replies
Jul 23, 2010
We're having an error similar to the one detailed here. We get the error noted above when trying to do AD authentication from our .net (3.5) mvc 2 app. This is our first .net mvc app ...
http://forums.asp.net/t/1161047.aspx
- We are re-using a forms auth library written for a .Net 2 app
- that library/app/config used a service account with min. privileges for binding to AD
- This error occurs in VS 2008, have not tried deploying the app to a server yet (a little early for that)
- like the other user at the previously referenced thread, I can get the 'unable to establish ...' error to go away and display the log on page by putting *MY* credentials in instead of the service account (but not successfully authenticate)
- moving the service account into the same AD OU as my account does not seem to change it ... only using my account credentials does.
- trust level is set to full
Is this some odd permissions trick that is new with .Net 3.5 (even though the ADmembershipProvider is still a 2.0 libary)? This should have nothing to do with MVC itself.
Config looks like this (very standard, like every one else's)
[Code]....
The line/portion highlighted in the debug/stacktrace is:
type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
View 2 Replies
Jul 15, 2010
How does one create new sites in your own custom directory? Can it be added as a feature?
View 2 Replies
Oct 1, 2010
Is there a simple way to fix elements in a html document that miss the ending tag, or /> ending? I'm using ASP.NET with c# (loads html with the help of Html Agility Pack).
An example:
<img src="www.example.com/image.jpg">
should transform into
<img src="www.example.com/image.jpg" />
or
<img src="www.example.com/image.jpg"></img>
View 1 Replies