MVC :: Routing Error On Default Route In Virtual Directory?
Feb 17, 2010
I have an application that I run in several places (demo, production, local, etc.) that all use different virtual directories for the placement of the MVC application.
I use StructureMap in this application, so I am overriding the ControllerFactory to use StructureMap to build controllers (when the passed controller instance is not null).
My problem is that the controller instance being passed to the controller factory IS null, which is fine if said route didn't exist, but it does... specifically, it should be my DEFAULT ROOT route.
Basically if I host the app at [URL], everything works fine except when I have a '/' on the end of the URL (meaning,[URL]... the latter works fine, while the former gives me the error). It looks like when that slash is there, the routing engine is deciding that it should be looking for a controller named MvcController, which doesn't exist, and which then passes the null controller instance to the ControllerFactory, resulting in the following error:
The controller for path '/Mvc/' could not be found or it does not implement IController.
My Default route is the standard default route. Removing all other routes has no effect. My default controller is HomeController.
View 3 Replies
Similar Messages:
Jul 21, 2010
I have an asp.net mvc 2 app (using .net 4.0) that isn't routing correctly when hosted in a virtual directory. I have the following simple routing rule:
routes.MapRoute(
"Default", // Route name
"{action}", // URL with parameters
new { controller = "accounts" } // Parameter defaults
);
I'm trying to resolve [URL]. Where "accounts" is a virtual directory. If I put the app in the root of an IIS website it routes fine for [URL], but if I put the app in a virtual directory I get 404 errors. I've debugged and it is executing global.asax and configuring routing when in the vdir. Is there something special I need to do for routing in a virtual directory? FYI. I'm using a vdir because the root has wordpress in it. one more thing is that if I specify a default action in parameter defaults, it will execute the default action/controller, but it never matches anything else.
View 2 Replies
Aug 23, 2010
I have an ASP.NET web application(WebForms,Not MVC) developed in VS 2008 and i have implemented ASP.NET web forms URL routing by following this link [URL]It works pretty good when i run it on the Visual studion IDE.But does not works when i created a site under my IIS (IIS 5.1 in XP) and deployed the same files there.I have set ASP.NET version as 2.0 in the Properties window of my application too.But does not work.
View 1 Replies
Nov 19, 2010
I have a Domain like [URL] that is pointed to a virtual directory on my webspace like [URL]. The folder structure on my webspace is (off course) like this
root
bin
VirtualDirectoryName
bin
Content
Scripts
Views
Web.config
Global.asax
If i call now [URL] i get the Site without CSS and the links are [URL]. I used the default and almost empty default "Internet Application". So the routing is default and all links are created with @Html.ActionLink. i tried so many things but i cant get it working. In my local environment i can affect that with IIS settings but (off course) i do not have access on the IIS settings of my host.
View 2 Replies
Sep 17, 2010
My hosting provider has ASP.NET 3.5 and I'm using MVC 2.0. I have two domains on my account, [URL], and [URL], each has it's own virtual directory off of the root:
/
/domainone
/domaintwo
Their routing commands for their httpd.ini rerouts [URL]to [URL] If I type in the address bar [URL], it works properly. The Problem My website links created using Html.ActionLink add the virtual directory. If you mouse over the About link in your standard MVC2.0 webapp, it displays as follows: [URL]
All of my testing and setup on my development machine doesn't have this virtual directory, and in the past my webhost didn't have this issue in the path. But since the move to their 'new' shared hosting platform, this is now what I'm having to deal with. How do I setup my ASP.NET MVC 2.0 web application to remove the unwanted virtual directory name from the path in my ActionLink controls?.....
View 4 Replies
Aug 31, 2010
I have a simple ASP.NET 3.5 application running under IIS7 under a virtual directory. So the URL of my app is like http://site.com/app. I want to 301-redirect the request to site.com/app/default.aspx to site.com/app for better SEO. I have to do this redirect through code only, not by any IIS settings. I am unable to do so via code mentioned in this article:
[URL]
The code:
if (request.RawUrl.Equals("/default.aspx"))
{
newUrl = string.Format("{0}://{1}{2}",
request.Url.Scheme,
request.Url.Authority,
request.RawUrl.Remove(request.RawUrl.LastIndexOf("/default.aspx", StringComparison.OrdinalIgnoreCase)));
context.Response.Status = "301 moved permanently";
context.Response.AddHeader("Location", newUrl);
}
seems to go into an infinite loop when the application is under a virtual directory. the request.RawUrl property always returns "/default.aspx" even after a 301 redirect causing the infinite loop.
View 3 Replies
Dec 2, 2010
i have developed website in MS framework 2.0 using Visual Studio 2005 Sql Server 2005 and Crystal Report 2008 (Version 12.0.0.549) due to some problem i have formated my pc and reinstalled Visual Studio 2005 Sql Server 2005 and Crystal Report 2008 sp3 (Upper version)on my pc now my website project running on IIS 5. is fine but when i open my website on visual studio 2005 it shows an error as below ...................
101 It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.
D:NayanAdvance_TestAdvancesystemweb.con
it need registry i think so, Now i did't get this error exactly
View 5 Replies
Jan 28, 2010
When I make a routing rule like
routes.MapRoute(
"Rule",
"Home_{action}/{id}",
new { controller = "Home", action = "Index", id="" }
);
"Home_MyAction" works (no id here). But with
routes.MapRoute(
"Rule",
"Home_{action}_{id}",
new { controller = "Home", action = "Index", id="" }
);
"Home_MyAction_" doesn't work (404 error).
Why is it so?
View 4 Replies
Feb 11, 2011
I am using iis 5.1 in which we have only only one default website, I have two projects v2 and v3 my website points to v2 projects and have some folders images, styles etc now i have a virtual directory under this website that is hosting project v3 and having the same folder hierarchy as v2 in the home page of the both projects i have img src="imagesedlogo.gif" alt="logo"/> but this shows the same image that is in the v2 directory, How can i show different images for both projects. using "" get the root of the web site but how can i get the root of virtual directory under that website
View 2 Replies
Jun 13, 2012
I defined a default error page in the ASP.Net Web Site Administration tool. The page exists in root directory. I also confirmed that it pointed to my frmErrorPage.aspx by looking in my Web.config file
Code:
<system.web>
<customErrors defaultRedirect="~/frmErrorPage.aspx" />
Running my site locally from within visual studio, I tried to surf to a non existent page. This threw an error as it is suppose to, but did not pull up my custom error page. I get
Code:
Server Error in '/' Application.
The resource cannot be found.
Description: HTTP 404. ...
View 8 Replies
May 11, 2010
I am creating virtual directory from my C# code when i execute this code working every finely.
But problem is when i publish this code and access through iis it is showing an error as access denied .
i tried to give permissions to the folder in c:\inetpub\wwwrootfoldername Network service and users provided permissions of full control But still showing an error of Access Denied(mine is iis 5.0 in xp)
View 2 Replies
Jun 30, 2010
I have a web application and I'm using asp.net routing. When I publish it with the Only files needed to run this application selected it gives me an error when I'm loading any of the page "HTTP Error 404 - File or directory not found."
but if I choose publish All files it works fine.
Do you know how to resolve this issue?
View 1 Replies
Nov 10, 2010
I have a WCF service in a virtual directory that is called in the code behind of a page that is in the parent directory, when i debug the code i can see the wcf service is being called, however when the service calls Membership.GetUser() it alway returns null. The user has already logged in to the asp.net site. When i call the service via jquery it does pick up the correct user, but i need to be able to call it via the code behind as well. I am developing in .Net 3.5 how i can make the Wcf pick up the logged in user?
View 3 Replies
Oct 27, 2010
I made a web form on a development website of mine (we'll call it dev.somewhere.com) and tried to publish it out to the web (we'll call it [URL]) in a subfolder. I named it default.aspx like I was supposed to and it worked flawlessly on the dev site. When I published it out the web, I wound up getting the following error when trying to get to the subfolder: [URL] Directory Listing Denied
This Virtual Directory does not allow contents to be listed. Confused and flustered, I tried to go to [URL], but I wound up with some error that won't tell me the problem. Instead it tells me to change the my web.config to read <customErrors mode="Off"/>.
View 1 Replies
Feb 13, 2010
As virutal directory points to physical path of the application, so if the IIS root directory is C:inetpubwwwroot and the application is stored at D:websites, than we need to create a virtual directory but if the application content is placed at C:inetpubwwwroot, then why still need to create virtual directory.
View 3 Replies
May 19, 2010
i'm new to routing in aspnet mvc.. i have following code:
[code]....
when i enter "localhost/school" in addressbar, it is giving 404 error instead it should route to my "schoolIndex" action
i have given route-name as "School" where it is used ?
View 1 Replies
Aug 4, 2010
I have a parent web application, called Parent, and a second web application called Child. Child is a virtual directory in IIS7 under Parent which is an application in IIS. Child is not a child directory of parent in the file system, only in IIS as a virtual directory. On application loading (Application_Start in global.asax) in the parent web application i tell it to load the child web dlls from childs bin folder using Assembly.LoadFrom() loading it into the app domain of Parent. Then when i try to visit /Child/Default.aspx I get an error saying: Parser Error Parser Error Message: Could not load type 'Child._Default'. Now the Child.dll (the web dll containing childs code behind etc) is in the app domain of the parent application and i can successfully reflect it and its members from code behind in the Parent page Default.aspx.
Furthermore on the Child/Default.aspx if i change the Inherits="Child._Default" to Inherits="System.Web.UI.Page" and then in <% %> tags on the page enumerate the dlls in the app domain i can see Child.dll and reflect its members and invoke functions. One thing that works is changing CodeBehind to CodeFile in the page directive. Then the page parses correctly. However this only works when the websites are in uncompiled, non published form.
View 1 Replies
Jul 30, 2010
I am building a forum based application and was wondering if I had to create a different route for each of the following scenarios: View Forums, View Topics, View Posts, Reply to Topic etc... Is there a single route that I can customize to catch all of these for the folllowing urls?
http://www.samplesite.com/forums
http://www.samplesite.com/forums/{forumID}
http://www.samplesite.com/forums/{forumID}/{topicID}
[code]...
Is there a custom route I can make to catch all of these instead of making a different route for each one?
View 1 Replies
Feb 18, 2011
I am building an application in Asp.Net 4.0 (Web Forms). I have used the feature of Routing introduced in this version of Asp.Net (4.0).
I have a few routes declared in my global.asax file. My problem is as long as the number of parameters (placeholders) declared in the route are different the right route is selected. But the moment the number of parameters (placeholders) declared in the route are same there is a clash and the Routing engine selects the wrong route. The only way I found was to use a Constant with one of the clashing routes to distinguish between the two. But I am sure there is a way out of it; I also tried using Regular Expression but still it selects the wrong route.
[Code]....
The last two routes have the same number of parameters so I tried to separate the second last route by adding a regular expression, but in vain.
View 19 Replies
Sep 6, 2010
i How can make the asp.net routing engine ignore routes with an extension of the type /pathtofile/filename.aspx/morepaths
I know this is hardly a real scenario but I need to know for another similar issue for an autogenerated url
View 1 Replies
Feb 8, 2011
I'm attempting to find a way to preventing a user from accessing a specific xml file. I've tried doing...
route "SiteMap",
"SiteMap/siteMap.xml",
new { },
new { isLocal = new LocalHostRouteConstraint() });
[code]...
View 1 Replies
Jan 25, 2011
How do I get the virtual url and not the webforms page name that the url is mapped to when using System.Web.Routing with webforms.
I want the url "/confirm/5" and not "Confirm.aspx".
View 2 Replies
Jan 12, 2011
I am using URL Routing to route user to his profile page, which is a child page. Now the problem is that all the images, javascripts references are distorted when i user the url to reach that page whether logged in or not logged in (both the cases). But after reaching this page when i login from this page thru my modal popup login control, all the references seem to work fine. It is to be noted that i am still in that same page which i reached after url routing. So upon logging from here the whole page works and displays fine.
How come the references are automatically adjusted when i am logging in from this page and are not referenced when i log in from other page and route here or when i am logged out?
Global.asax code:
void Application_Start(object sender, EventArgs e)
{
RegisterRoutes(RouteTable.Routes);
}
public static void RegisterRoutes(RouteCollection routes)
{
routes.Add("UseridRoute", new Route
(
"profile/{user}",
new CustomRouteHandler("~/UserProfile.aspx")
));
}
View 2 Replies
Aug 20, 2010
I am able to route my urls to an existing page. Here is how our scenario is currently working:
On Default.aspx, we have several links that link to pdf files on the server. The filenames of these files change dynamically which is why we need the url routing. When the user clicks on of the urls, the link is routed to the getFile.aspx page that has logic in it to determine which file to open.
Is there a way to have the getFile.aspx page to open in the same window as the default.aspx page?
Otherwise, I need for the getFile.aspx page to close after the intended processing is complete, and I've not been able to close it without getting the close window dialog box. I figure if it opens in the same browser window, I can redirect back to the default.aspx page when processing is finished.
View 1 Replies
May 7, 2010
I am using asp.net C#/3.5 and stuck.
PHP Code:
Route myroute1 = new Route("{controller}/{action}/{slug}", new MyRouteHandler());
Route myroute2 = new Route("{controller}/{action}", new MyRouteHandler());
Route myroute3 = new Route("{controller}", new MyRouteHandler());
Routes.Add(myroute1);
Routes.Add(myroute2);
Routes.Add(myroute3);
[code]...
View 12 Replies