Can I specify a custom location to “search for views” in ASP.NET MVC?

You can easily extend the WebFormViewEngine to specify all the locations you want to look in: public class CustomViewEngine : WebFormViewEngine { public CustomViewEngine() { var viewLocations = new[] { “~/Views/{1}/{0}.aspx”, “~/Views/{1}/{0}.ascx”, “~/Views/Shared/{0}.aspx”, “~/Views/Shared/{0}.ascx”, “~/AnotherPath/Views/{0}.ascx” // etc }; this.PartialViewLocationFormats = viewLocations; this.ViewLocationFormats = viewLocations; } } Make sure you remember to register the view engine … Read more

“Could not load type [Namespace].Global” causing me grief

One situation I’ve encountered which caused this problem is when you specify the platform for a build through “Build Configuration”. If you specify x86 as your build platform, visual studio will automatically assign bin/x86/Debug as your output directory for this project. This is perfectly valid for other project types, except for web applications where ASP.NET … Read more

How can I get the button that caused the submit from the form submit event?

I leveraged document.activeElement as sketched in this answer: How to get the focused element with jQuery? $form.on(‘submit’, function() { var $btn = $(document.activeElement); if ( /* there is an activeElement at all */ $btn.length && /* it’s a child of the form */ $form.has($btn) && /* it’s really a submit element */ $btn.is(‘button[type=”submit”], input[type=”submit”], input[type=”image”]’) … Read more

Best way in asp.net to force https for an entire site?

Please use HSTS (HTTP Strict Transport Security) from http://www.hanselman.com/blog/HowToEnableHTTPStrictTransportSecurityHSTSInIIS7.aspx <?xml version=”1.0″ encoding=”UTF-8″?> <configuration> <system.webServer> <rewrite> <rules> <rule name=”HTTP to HTTPS redirect” stopProcessing=”true”> <match url=”(.*)” /> <conditions> <add input=”{HTTPS}” pattern=”off” ignoreCase=”true” /> </conditions> <action type=”Redirect” url=”https://{HTTP_HOST}/{R:1}” redirectType=”Permanent” /> </rule> </rules> <outboundRules> <rule name=”Add Strict-Transport-Security when HTTPS” enabled=”true”> <match serverVariable=”RESPONSE_Strict_Transport_Security” pattern=”.*” /> <conditions> <add input=”{HTTPS}” pattern=”on” ignoreCase=”true” … Read more

A potentially dangerous Request.Path value was detected from the client (*)

If you’re using .NET 4.0 you should be able to allow these urls via the web.config <system.web> <httpRuntime requestPathInvalidCharacters=”&lt;,&gt;,%,&amp;,:,\,?” /> </system.web> Note, I’ve just removed the asterisk (*), the original default string is: <httpRuntime requestPathInvalidCharacters=”&lt;,&gt;,*,%,&amp;,:,\,?” /> See this question for more details.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)