Front end users are free to upload images of any size, However for uniformity its often necessary to resize these images to a standard width and height but still maintaining the aspect ratio. The following function is what I use to to resize an image dynamically. The file thus returned can then be renamed and […]
asp.net
Disallow Model to retain its state in MVC 3
By default when a page is posted back in MVC3 it retains the form values. so on redisplay of the same page, we find the values are retained. In case this need to be disallowed the following can be used so the model does not retain its state. ModelState.Clear(); It can also be used […]
Avoid Redirect to Login Page
When the following authorization is set in the config file at the site’s root, inside the system.web node, we notice that no object is rendered unless the user gets authenticated. This also includes images, style sheets, javascripts etc. <authorization> <deny users="?" /> <allow users="*" /> </authorization> In cases like these, we […]
Cross Domain Ajax using jQuery
Browsers by default don’t allow cross domain ajax. Conceptually we can implement JSONP (see http://en.wikipedia.org/wiki/JSONP) using jquery to do this. Here is an example <script type="text/javascript"> $(document).ready(function () { var s = $.ajax({ url: "http://someotherdomain.com/page?callback=?", context: document.body, dataType: "jsonp" }); }); function populate(data) { $(".info").html(unescape(data)); } </script> <button id="btn" value="click me" /> <div […]
Setting IIS ASP.net site to work with https only and not http
Recently we had installed a SSL certificate on one of our sites and the requests with https were being served perfectly as expected, however it was noticed that the pages were still being served perfectly even when an http request was made instead of https. This to an extent was defeating the purpose of having a certificate in place to serve secured content.
Visual Studio 2010 intellisense autofill
I have been facing a problem with Visual studio 2010’s intellisense. Firstly it didn’t show any intellisense options until I hit a Cntl+space and when I fixed that the auto fill would not complete until you manually select the required option from the intellisense list.