What is the most straightforward way to prevent hotlinking in ASP.NET MVC 3 and IIS7?
Thanks.
Remember, ASP.Net MVC 3 is still ASP.Net underneath. Which means you can use standard methods. For example the LeechGuard Module provided by Microsoft.
Related
I have a number of "old-style" ASP.NET 4.x Webforms applications. For future development, we're thinking about switching to ASP.NET MVC 5, and we plan to basically add new features as MVC code to our existing apps.
Now I found a number of interesting articles on how to mix Webforms and ASP.NET MVC, and one of the topics usually is around routing. Typically, the consensus is to define a "route ignore" setting for all *.aspx requests - those get handled by the "old" Webforms runtime.
This is all nice and fine - but we're already using the Webforms "friendly URL" feature - so our requests are like
http://myserver.com/myapp/customer/42
http://myserver.com/myapp/product/edit/57
and we don't have any ".aspx" in our query string anymore.
So given this setup - Webforms 4.5.x with Friendly URL's (without the ".aspx" indicator) - how do I make sure that my new MVC routes don't collide with existing Webforms friendly URLs ?
Do I need to stick all the MVC stuff into an "area" (or several) and just define those URLs as the MVC routes? E.g.
http://myserver.com/myapp/mvc/newhotness/404
***
or are there other, more compelling approaches to this?
ASP.NET MVC 4 has some nice mobile features which are replacing my mutant mobile view engines, but until it's production ready, I'd like to implement the browser override feature for ASP.NET MVC 3.
SetOverriddenBrowser() seems to set a .ASPXBrowserOverride cookie with an overriding User Agent that returns an HttpBrowserCapabilitiesBase object via HttpContext.GetOverriddenBRowser().
What would be the simplest way of implementing this feature for MVC 3 to make use of the mobile detection library, including 51Degrees.mobi?
There is a blog post on the 51Degrees.mobi site that you might find useful. Check it out here. It covers the implementation of 51Degrees with MVC 4.
ASP.NET MVC 3 (final) was released today. When this version was in its infancy I remember reading on codeplex that donut caching was being considered. Does anyone know if this made it into V3? I cannot seem to find any information so I can only (sadly) assume that it didn't happen.
Yes, it is. Scott Gu blogged about it:
In addition to supporting full page
output caching, ASP.NET MVC 3 also
supports partial-page caching – which
allows you to cache a region of output
and re-use it across multiple requests
or controllers. The [OutputCache]
behavior for partial-page caching was
updated with RC2 so that sub-content
cached entries are varied based on
input parameters as opposed to the URL
structure of the top-level request –
which makes caching scenarios both
easier and more powerful than the
behavior in the previous RC.
UPDATE:
Out of the box only donut hole caching is supported in ASP.NET MVC 3. This allows you to cache a small portion of the page by using the [OutputCache] attribute on a child action. Donut caching which allows for excluding portions of a page that has been cached is not supported. Response.WriteSubstitution doesn't work since ASP.NET MVC 2. Here is a good article which explains the different caching options available in ASP.NET MVC 3.
UPDATE 2:
Here's a great article which illustrates how donut caching could be enabled in ASP.NET MVC 3.
Here's a slightly more detailed example from Scott, using Razor syntax.
Donut Caching (yes, the real thing) is available as part of my 'speed-lib' for MVC: Moth. Works in both ASP.NET MVC 2 and MVC 3.
Docs are at the wiki, and examples are in the Mvc3.Demo folder
I found a NuGet package MvcDonutCaching mentioned by Denis Huvelle which solves the problem for 3 & 4 - but I haven't tested it.
I've seen this posted alot that solves the problem if you are running ASP.Net application not a MVC 2 one in IIS 7.5. Would the same solution work using location in the web.config and 2 seperate login pages like it does for asp.net? Do you need to register a new route to do that?
I know it would work with 2 seperate applications in IIS, but i want them all in the same application. Any ideas?
Solutions for asp.net
http://mvolo.com/blogs/serverside/archive/2008/02/11/IIS-7.0-Two_2D00_Level-Authentication-with-Forms-Authentication-and-Windows-Authentication.aspx
Mixing Forms authentication with Windows authentication
http://craigandera.blogspot.com/2004/07/mixing-forms-and-windows-authentication_24.html
It looks like you can use the following solution.
http://mvolo.com/blogs/serverside/archive/2008/02/11/IIS-7.0-Two_2D00_Level-Authentication-with-Forms-Authentication-and-Windows-Authentication.aspx
But i had to create a ASP.net page inside my MVC solution that gets hit directly to handle the Windows Authentication then redirects to the mvc site. The location section inside of the web.config should work then since it's not relying on the routing.
Can it easily be combined with jQuery, (ASP.NET) Ajax, ASP.NET webforms, other frameworks.
What about pulling dynamic code from ASP.NET MVC into for example classic ASP?
Does the MVC model mean that it is easy to customize code?
Background:
I have some experience that it can lead to problems to integrate frameworks relying on JavaScript with each other?
We have a classic ASP where we write new stuff in ASP.NET, and include .aspx code in the ASP files.
I am looking for some OS frameworks for stuff we need, and i think MVC based ones should be easier to adopt (KIGG)
ASP.NET MVC ships with jQuery as the default javascript framework, so no worries there. There aren't really any ties in the framework itself to jQuery so you could also switch it out with a framework of your choice. MVC comes with it's own AJAX implementation that builds on the base ASP.NET Ajax implementation (at least in javascript), so there is AJAX support but I think you'll find that it's different -- no UpdatePanels, for instance -- but you're able to do similar things.
You can mix WebForms with MVC, but you'll need to set up IgnoreRoutes for those URLs so they don't get processed. I confess that I haven't found a need to do this yet, but then I don't use third-party controls. That might be an area where, at least for now, you still need some WebForms. I've never used classic ASP and likely won't so I can't help you there.
You can use any Javascript framework with MVC, they have included Jquery as the default but any can work with it.
As far as flexibility, we have deployed a working site with ASP.NET webforms, MVC and .NET 1.1 libraries, so yes it is flexible.
In our experience ASP.NET MVC is the best thing MS have done for web development, especially if you like to control closely your html output and use web standards in your layout and design. We have used it for 6 Months and we are NEVER going back to web forms.
Have fun!