How can I implement Ninject or DI on asp.net Web Forms?

Here are the steps to use Ninject with WebForms. Step1 – Downloads There are two downloads required – Ninject-2.0.0.0-release-net-3.5 and the WebForm extensions Ninject.Web_1.0.0.0_With.log4net (there is an NLog alternative). The following files need to be referenced in the web application: Ninject.dll, Ninject.Web.dll, Ninject.Extensions.Logging.dll and Ninject.Extensions.Logging.Log4net.dll. Step 2 – Global.asax The Global class needs to derive … Read more

Calling a ‘WebMethod’ with jQuery in ASP.NET WebForms

Make sure that you have enabled page methods in your ScriptManager element: <asp:ScriptManager ID=”scm” runat=”server” EnablePageMethods=”true” /> and that you have canceled the default action of the button by returning false inside the onclick handler, otherwise the page performs a full postback and your AJAX call might never have the time to finish. Here’s a … 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