ASP.NET Cafe
new tricks every week

MVC: authorization action filters

Sunday, 25 July 2010 09:47 by dmitriy

How to protect some controller action(s) from being accessed by unauthorized users?

Usually you can check this.User.Identity.IsAuthenticated in each action. But that doesn't look good, does it?

What if we can have an attribute to mark actions accessible only by logged in users?

More...

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:  
Categories:   ASP.NET | MVC
Actions: E-mail | del.icio.us | Kick it! | DZone it! | Permalink | Comments (0) | Comment RSSRSS comment feed

How to Speed up aspnet_compiler

Monday, 16 November 2009 21:49 by dmitriy

Here is one trick to greatly speedup asp.net compiler. First of all, assume you have enough RAM to give about 512Mb for this. RAM is cheap, so you always can visit store and buy it. And your time is priceless. 

Idea is in creating RAM drive and pointing asp.net compiler temp there. To create RAM drive you need to download following free software

http://www.ltr-data.se/opencode.html#ImDisk

IMDisk - awesome thing. Install it.

Now create ramdrive.cmd somewhere ( for example c:\ramdrive.cmd ) with following content

imdisk -a -s 512Mb -m R: -p "/fs:ntfs /q /y"  

create a shortcut and add it to Startup

Now everytime you start PC you'll see quick console window and you'll got a new drive "R"

Ok. Now you need to change your temp settings

Edit this file: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG\web.config  

( I assume that you've Windows installed in C:\Windows . Change path if it's different )

 In this file you need to add attribute to <compilation> tag

After change it should look like this: 

        <compilation tempDirectory="r:/asp.net_temp" > 

That's all. Now you can build your asp.net projects much faster. You can try to point all windows Temp on that RAM drive, but I haven't gone this far yet. 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:   ,
Categories:   ASP.NET | Main
Actions: E-mail | del.icio.us | Kick it! | DZone it! | Permalink | Comments (1) | Comment RSSRSS comment feed

Enter button and several inputs

Thursday, 2 July 2009 09:43 by dmitriy
In ASP.NET you have sometimes a problem. When you have several inputs (textboxes) and several buttons. You want user to submit it by hitting enter. For example one login box, one search box. You want to submit login box when user hits enter in password field, and search button when user hits enter in search field. The solution is easy! Just put controls inside the asp:panel with attribute DefaultButton="ButtonFind"  ( where ButtonFind is ID of desired default button ). That's all! It works!

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:  
Categories:   ASP.NET
Actions: E-mail | del.icio.us | Kick it! | DZone it! | Permalink | Comments (0) | Comment RSSRSS comment feed

MailEnable - How to add new mailbox from code

Tuesday, 10 February 2009 03:49 by dmitriy

Mailenable is quite good Mail Server for windows. It has a free version ( and that's version works good if you don't need WebMail ).

Here is some code to add mailbox to PostOffice.

More...

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:   ,
Categories:   ASP.NET | C# | Main
Actions: E-mail | del.icio.us | Kick it! | DZone it! | Permalink | Comments (0) | Comment RSSRSS comment feed

ASP.NET 2.0 Big files upload on IIS 6.0 under Win2003

Saturday, 2 August 2008 06:21 by dmitriy

Recently faced the big problem with big files. Not so big, just needed to post files with size about 10-20MB to aspx page. With usage of quite standard control on the page.

Everybody know ( if not - I notice here ) that in web.config you have HttpRuntime settings. And one of these settings is  maxRequestLength .In theor, after adding of this line to web.config file everything should work fine.

 <httpRuntime maxRequestLength="100000"/>

But in fact you can face the problem of limit in IIS. And this is a pain in the ass. Because you need to edit Metabase.xml on server. Sometimes this can be impossible, but sometimes you can do this yourself or ask support. Here is some insturctions to make big files uploads work for you.

More...

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:  
Categories:   ASP.NET
Actions: E-mail | del.icio.us | Kick it! | DZone it! | Permalink | Comments (0) | Comment RSSRSS comment feed