Igor Kitsula - Developer

A Programmer Reference

 
  1  2  3  4  

Versioning JavaScript and CSS files or How to update static files on client side

If you have enabled expiry headers, entity tags, etc. (and even if not), anyway most of the browsers have enabled cache. But how can we force client browser to load new version of JavaScript file or CSS static file? Especially if you did a change in any site specific static file. File from browser cache can broke behavior of website or/and design. So how to tell browser to load updated static file?

Read more...Read more...

How to Deploy an ASP.NET MVC 3 App to Web Hosting with "\bin Deployment"

If your hosting provider don’t support MVC 3 but have MVC 2 installed you still can deploy your web app. Solution is simple – MVC 3 files should be in Bin folder of your solution. Here is the list:

Microsoft.Web.Infrastructure.dll
System.Web.Helpers.dll
System.Web.Mvc.dll
System.Web.Razor.dll
System.Web.WebPages.dll
System.Web.WebPages.Deployment.dll
System.Web.WebPages.Razor.dll

Read more...Read more...

How to Compress components with gzip OR Enable dynamic and static compression

According to the YSlow article compressing with gzip generally reduces the response size by about 70%.
As we can see little change in settings can improve performance of website.
As this is IIS web server setting you can configure it in two ways:

Read more...Read more...

How to: Turn on MVC compiled views or Turning on views compilation

Turning on views compilation will tell the compiler to compile your views and you will catch any errors (in views code) whenever you compile. Very handy and saves sometime. Unfortunately, it does add some time to the build process. If you have a lot of views, this could be lengthy, so you may want to disable this later.

Read more...Read more...

Image + ActionLink = Html.ImageActionLink

If you want to put image inside link using HTML.ActionLink you can use next nice implementation of extension method:

Read more...Read more...

ASP.NET MVC Razor - output HTML string non escaped

How do you show (safe) HTML saved in DB in a Razor view? It always escapes stuff like <.

Supposing your content is inside a string named mystring...

In releases from Beta 2 and earlier you can do:

@(new HtmlString(mystring))

In releases after Beta 2 you will be able to do:

	@Html.Raw(mystring)

Source:

ASP .NET MVC 3: JQuery validation and Data Annotation or Unobtrusive Client Validation

In previous article I’ve show you how to validate form using jQuery validation plugin and view model Data Annotations. With MVC 3 Microsoft have implemented jQuery validation referring to standard Data Annotation attributes. Let me show you how to use it in simple example.

Read more...Read more...

MVC Handling and logging JavaScript errors

Most of browsers have window.onerror event which fired when JavaScript error occur. You can bind your function to this event which receives three parameters: message, URL and line number where error raised.

Let’s create function which will be graceful handling of JavaScript errors, send in poor JavaScript AJAX request all information about error and then we can log it with Log4Net and send email notice.

Read more...Read more...

MVC Custom Error Pages (Log to database with Log4Net and notify by email)

MVC Custom error pages (log to database with Log4Net and notify by email)
There is a lot articles in web how to create and use custom error pages. I tried to implement one more solution and give you my example how to handle and log errors on website using Log4Net library and notify about error by email.

Read more...Read more...

Using jQuery to submit ASP .NET MVC form

Simplest, easier and nice method to submit MVC form using jQuery AJAX:

$("formMapMarker").submit(function(e) {
	if ($("formMapMarker").valid()) {
		$.post($(this).attr("action"), $(this).serialize());
	}
	e.preventDefault();
});
Read more...Read more...
  1  2  3  4