All my requests ending with any extension like .jpg, .gif are throwing 404. The content for these requests are served from database. It works if i append a trailing backslash to the request.
http://www.example.com/1.jpg doesn't work
http://www.example.com/1.jpg/ Works
i have runAllManagedModulesForAllRequests set to true but i think it's not used in 7.5.
This also work perfectly fine in my box but doesn't in a test box.
I edited my web.config and added the following to get .json to work.
<handlers>
...
<add name="MyJsonHandler" path="*.json" verb="*" type="System.Web.UI.PageHandlerFactory" resourceType="Unspecified" preCondition="integratedMode" />
</handlers>
You can do this manually in your web.config or use IIS to manage it in the HTTP Handlers for the web site you are configuring.
Related
I want to configure a wildcard mapping for a specific path, and send the requests to a HttpHandler. My URLs look like this:
http://www.example.com/api/v1/conversation/forums/232?some=value
http://www.example.com/api/v1/conversation/posts/212
This configuration doesnt match the URLs above.
<location path="api/v1/conversation">
<system.webServer>
<handlers>
<add name="ApiProxy" verb="*" path="*" preCondition="integratedMode" type="DemoProject.ApiProxy, DemoProject" />
</handlers>
</system.webServer>
</location>
It works when I add an extension to my URLs:
http://www.example.com/api/v1/conversation/forums/232.axd?some=value
http://www.example.com/api/v1/conversation/posts/212.axd
How do I make this work extension-less?
It turned out, that this problem was related to my website was running Umbraco CMS. Umbraco CMS has an AppSetting called "umbracoReservedPaths", which asks Umbraco to ignore specific paths.
The value was set to:
<add key="umbracoReservedPaths" value="~/umbraco,~/install/" />
After adding ~/api/, everything worked as expected:
<add key="umbracoReservedPaths" value="~/umbraco,~/install/,~/api/" />
Masters,
In my MVC application many pages are static (HTML pages).
I've to create both .cshtml and plain HTML pages.
HTML version is also in use by another module.
When I try with return View("Mypage.html") it fails.
Is there any way to consume plain "HTML" pages for my View.
Please help.
What I did in the past was to register ".html" pages to be interpreted as dynamic pages, too. (I.e. just like ASPX).
This can be done through your "web.config" file:
....
<
system.web>
<compilation ...>
<buildProviders>
<add extension=".html"
type="System.Web.Compilation.PageBuildProvider" />
</buildProviders>
....and
....
<system.webServer>
<handlers>
<remove name="WebServiceHandlerFactory-Integrated" />
<add name="PageHandlerFactory-Integrated-HTML" path="*.html"
verb="GET,HEAD,POST,DEBUG" type="System.Web.UI.PageHandlerFactory"
resourceType="Unspecified" preCondition="integratedMode" />
</handlers>
this works well with IIS 7 and IIS 7.5 (and probably on above versions, too). If you are using IIS 6, you have to do it through the IIS Management Console.
Hope this helps..
I had started creating a new theme while using v1.6.1.
Things were not going well with a custom module creation so I decided to start from scratch. This time I am using the source from V1.7
I copied my custom theme folder, pasted it into the themes folder of the new 1.7 project and ran the site. I could see the theme in my dashboard so I set it to the current theme.
Now when I view my site NONE of the images are loading. The style sheets are loading, though none of the images - either from the style sheet or from any views - are loading.
My images are in myTheme/content/images - which as I understand it is how 1.6.1 required things to be laid out.
My content folder has a web.config as does my images folder. It's the same config used in 1.6.1 so I'm wondering if something has changed.
In one of my theme views I have the following code - this worked in 1.6.1:
<img src="#Url.Content(Html.ThemePath(WorkContext.CurrentTheme,"/Content/Images/phoneBullet.png"))" alt="T:" />
If I output this to my front-end I get:
~/Themes/PerformanceAbrasives/Content/Images/phoneBullet.png
This tells me things appear to be in the correct place - though I'm wondering if my web.config is now out of date?
I have this - there is a copy in content and a copy in images:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appSettings>
<add key="webpages:Enabled" value="false" />
</appSettings>
<system.web>
<httpHandlers>
<!-- iis6 - for any request in this location, return via managed static file handler -->
<add path="*" verb="*" type="System.Web.StaticFileHandler" />
</httpHandlers>
</system.web>
<system.webServer>
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="7.00:00:00" />
</staticContent>
<handlers accessPolicy="Script,Read">
<!--
iis7 - for any request to a file exists on disk, return it via native http module.
accessPolicy 'Script' is to allow for a managed 404 page.
-->
<add name="StaticFile" path="*" verb="*" modules="StaticFileModule" preCondition="integratedMode" resourceType="File" requireAccess="Read" />
</handlers>
</system.webServer>
</configuration>
Any pointers?
UPDATE
Ok... so if I set my project to use Visual Studios internal development server then all is well - if I tell it to use Local IIS Web server - use IIS Express (http://localhost:30333/) - then it doesn't work...
UPDATE 2
Ok - now running from IIS 7 and images do not load... stylesheets seem ok, but images are not.. grrr
any ideas so I don't run into this problem when I deploy?
Ok - I figured it....
You only need the web.config in my Content directory - not in both content AND images
I would like to have define a bundle like this:
bundles.Add(
new StyleBundle("~/style.css").Include(
//...
));
If the bundle name is just "~/style" this works, but with the file extension it always returns a 404. I suspect the server searches for CSS and JS files on the drive and ignores the bundling system, but I can't find anyone else who is trying to include file extensions in bundle names. Is this possible to do without something like a URL rewrite?
You could add the following to your <system.webServer> section in web.config:
<modules runAllManagedModulesForAllRequests="true" />
This will ensure that requests for static resources such as .js and .css will pass through the managed modules and be intercepted by ASP.NET MVC.
As an alternative to enabling runAllManagedModulesForAllRequests for all requests you could configure them only for the urls you need to use. So inside the <handlers> add the following:
<handlers>
<!-- ... -->
<add name="scriptBundle" verb="*" path="script.js" type="System.Web.Optimization.BundleHandler, System.Web.Optimization" preCondition="managedHandler" />
<add name="cssBundle" verb="*" path="style.css" type="System.Web.Optimization.BundleHandler, System.Web.Optimization" preCondition="managedHandler" />
</handlers>
By default the web.config file for MVC project have the following element:
<handlers>
<remove name="MvcHttpHandler"/>
<add name="MvcHttpHandler" preCondition="integratedMode"
verb="*" path="*.mvc" type="System.Web.Mvc.MvcHttpHandler"/>
</handlers>
My problem is that my site returns 404.14, after knocking out all the usual suspects I changed the path (form the snippet above) attribute in the web.config to be "*" and voilĂ ! MVC handler kicks in.
So my question is how does *.mvc even suppose to work? I mean my urls are http://mysite.com/home/index (or even only http://mysite.com/) there is no *.mvc in them.
Am I missing something?
By changing the path you are telling the routing engine to add the .mvc extension to the Url. You probably do not have the .mvc extension mapped in IIS and receive an error.
See here on information about IIS and MVC especially if you are using IIS 6.0:
http://haacked.com/archive/2008/11/26/asp.net-mvc-on-iis-6-walkthrough.aspx