mvc3 on iis6 , only home page works , routes gives 404 - iis

I've deployed a MVC3 application to a win2003 server with .Net4.0 installed . I've configured wildcard mapping for application as described here . Also i did it before for other mvc3 applications on the same server before . I'm sure that the IIS configurations of both mvc3 applications are same.
When i hit the default home page of the default route, it works, but other controllers and actions gives 404. I can't figure out a way for 2 days . Any help will be great.
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new {controller = "Home", action = "Index", id = UrlParameter.Optional} // Parameter defaults );

Make sure that ASP.NET 4.0 is properly registered with IIS 6.0
c:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -i
and that it is enabled:

Verify below items in IIS
Home Directory tab -> Configuration. Under Wildcard application maps,
1.the entry aspnet_isapi.dll has been added
2."verify file exists" checkbox should be in unchecked state

Related

Azure does not see Index.cshtml

I'm trying to publish my ASP.NET Core application on Azure service. This works, but when I try to use the application functionality, I get the message
Your App Service app is up and running.
Moreover, in my wwwroot folder I don't have any .html files. I only have an Index.cshtml file, which is located in the Views/Home-folder in my application, all another files are .css, .js, etc.
When I run the application in Visual Studio in Debug mode, immediately opens the page in browser that was generated from Index.cshtml. But after the application is published in Azure, this does not happen.
What can I do to make Azure see Index.cshtml?
AFAIK, a default route would be added to Configure method of your Startup.cs file as follows:
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
I also created my .Net Core 2.0 MVC application to check this issue, it could work as expected on local side and my azure web app.
Moreover, in my wwwroot folder I don't have any .html files.
Views under Web Application and Web Apllication MVC would be compiled into {your-webapplication-assemblyname}.PrecompiledViews.dll, you could leverage ILSpy to check your DLLs.
For your issue, I would recommend you clear the web content in your web app via KUDU, or modify the publish settings and choose Remove additional files at destination under File Publish Options, then redeploy your application to Azure Web App to narrow this issue.
Are you finding index.cshtml in your web package? In case if you get index.cshtml in your final web package, you may need to add index.cshtml file type to the following in..
..YourAzureWebApp --> Application Settings --> Default Documents
I found out what the problem was. There are two types of applications, as presented below in the picture: Web Application and Web Apllication MVC. I worked with the second type of application. When I selected the first type and published the application, Azure immediately found the required index.html. I just had to choose Web Application.
But why does not it work with the second type of application (Web Apllication MVC)? I still do not know the answer to this question.
2 cents from my side as I just stuck for a while with this.
The problem was that yesterday I'd been playing around with deploying to Ubunut / Ngnix and today I decided to try Azure.
BUT I forgot to comment (disable) the following lines in my Startup:
//for nginx server
app.UseForwardedHeaders(new ForwardedHeadersOptions
{
ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
});
and that costed me almost half of the day to find the issue.
I also put the routing in the following way
app.UseStatusCodePages();
app.UseAuthentication();
app.UseMvc(routes => {
routes.MapRoute(
name: "default",
template: "{controller=Pages}/{action=Index}");
});
Now looks like it works on Azure :)

nopCommerce store with a custom plugin web deploy issue

NopCommerce version: 3.9
I've designed a web store using NopCommerce 3.9. Any code I added is in a plugin.
The store uses a front page that can be found in the plugin. It relies on a route called 'home' in a RouteProvider class in the plugin. It does not complain about that route, instead it complains about a route named 'RegisterVendor' found in the same file. Here are both routes
routes.MapRoute("home",
"",
new { controller = "AoiVendorsHome", action = "Index" },
new[] { "Nop.Plugin.Other.AoiVendors.Controllers" });
routes.MapRoute("RegisterVendor",
"register/designer",
new { controller = "AoiExchange", action = "RegisterVendor" },
new[] { "Nop.Plugin.Other.AoiVendors.Controllers" });
The plugin installs properly and everything works exactly as expected on my local machine.
The problem is after deploying to the web it can't find the route. Here is a imgur link, follow it to see the error
Restarting the server fixes the error for a while, but it does eventually come back. It also comes back any time I redeploy without restarting the server afterwards.
Does anyone have any ideas?
Thank You.
The "HomePage" route of nopCommerce is registred this way
//home page
routes.MapLocalizedRoute("HomePage",
"",
new { controller = "Home", action = "Index" },
new[] { "Nop.Web.Controllers" });
Check your load order: If your registration does not hit first, remove nopCommerce "HomePage" route and add yours or add yours first using the Priority property of IRouteProvider.
MVC uses the route that first matches the request.
Regarding the deployment problem, make sure your plugin is deployed to ~/Plugins/{yourPluginFolder} and not the bin folder of Nop.Web. Plugin in ~/bin folder can be loaded but without guarantee.
I was able to fix the issue by selecting the 'Remove additional files at destination' checkbox under file publish options on the settings tab in the publish popup dialog in visual studio. I imagine an older file was not being overwritten and was causing problems.

Swashbuckle running with katana-owin based web api doesnt work with IIS but works with IIS Express

I think I have a similar issue as this post-
Webactivator doesn't run on IIS 7
Swashbuckle running with katana-owin based web api is able to work with IIS Express.
assume all the urls below have an "http" prefix.
I can browse to something like localhost:8085/swagger Which redirects me correctly to localhost:8085/swagger/ui/index
But when published to IIS redirects to localhost/swagger/ui/index instead of localhost/myapp/swagger/ui/index and this results in a 404. Notice that even though an application name is specified while publishing somehow swashbuckle/swagger doesn't know and only uses the pathbase without the application name.
basically it just picks up the site root URL instead of the application URL that was used to call /swagger
Any solution to this problem?
I got the same issue. Solved this using the following code (c.RootUrl)
config.EnableSwagger(c =>
{
c.IncludeXmlComments(GetXmlCommentsPath());
c.SingleApiVersion("v1", "yourAPI");
c.RootUrl(req => req.RequestUri.GetLeftPart(UriPartial.Authority) + VirtualPathUtility.ToAbsolute("~/").TrimEnd('/'));
});
Reference : Relative path for UI request URL

IIS 8.5 MVC 5 Routes 'api/controllerName' gives 404 Not Found Error

Within a MVC 5 Webapi project, I am trying to do a GET request via jquery using URL 'api/controllerName'. The web application is hosted under Default Website and the root of the webisite is "localhost/myApp".
The route 'api/controllerName' gets translated to 'localhost/api/controllerName' instead of 'localhost/myApp/api/controllerName' throwing 404 Not found Error.
This has to do something with IIS 8.5 and MVC 5 routing, because:
The Same setup works well on IIS 7.5
The same set up works well on IIS 8.5 if i do not use a virtual directory and host the application directly at Default Web Site.
My Global.asax.cs's RegisterRoutes Method looks like below
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
I figured this out. Apparently, IIS 7.5 worked fine with the bare route 'api/controllerName' but IIS 8.5 needed a fully qualified route created using #Url.RouteURL utility with RouteName as "DefaultApi".
i replaced the URL with
'#Url.RouteUrl("DefaultApi", new { httproute = "", controller = "controllerName"})'
and it worked like a charm (on both IIS 7.5 and IIS 8.5).

Setting up Web.config to work Side-by-Side with ASP.NET MVC 4 - Location Tag not resolving value "api"

I checked out Run servicestack side by side with another web framework.
When I add the location tag the "api" is unresolved...what do I need to do to get the location tag to be aware of "api"?
Firstly make sure you follow the README.txt instructions for running ServiceStack in ASP.NET MVC.
ServiceStack automatically infers the handler path based on the <location> tag, if there's more than one or it has some other issue inferring, it can be explicitly set in Config.ServiceStackHandlerFactoryPath, e.g:
SetConfig(new EndpointHostConfig {
ServiceStackHandlerFactoryPath = "api",
});

Resources