Browse by Tags

How to switch between HTTP and HTTPS in ASP.NET MVC2
ASP.NET MVC2 has the new RequireHttpsAttribute that you can use to decorate any action to force any non-secure request to come through HTTPS (SSL). It can be used as simply as this: [RequireHttps] public ActionResult LogOn() { ..... } Now any request...
How to 301 Permanent Redirect in ASP.NET
In the next release of the .NET Framework (.NET Framework 4.0) there is a new response method for permanently redirecting a request: Response.RedirectPermanent . You can see the Beta MSDN documentation for Response.RedirectPermanent here . This will automatically...
Line-breaks and carriage returns (\r \n) are invalid in email subject
I received this exception when sending an email using System.Net.Mail.MailMessage: "The specified string is not in the form required for a subject." System.ArgumentException: The specified string is not in the form required for a subject.   ...
Handle the button click event from an ASP.NET ListView control
Here is how you can handle the event of a button from within an ASP.NET ListView control. Add your button to the ListView Template like you would any other control: <asp:ListView ItemPlaceholderID="Test" runat="server" ID="ListView1"...
Generating a random strong password
You can use the ASP.NET Membership provider to generate a new random strong password. In the past I have usually either rolled my own authentication system or integrated an asp.net authentication system into an existing application and therefore I did...
Asynchronously sending a System.Net.Mail.MailMessage in C#
When sending an email in your ASP.NET application there are times when you do not want the user experience to slow just to wait for an email to be sent.  The code sample below is how to send a System.Net.Mail.MailMessage asynchronously so that the...
How to disable an ASP.NET button when clicked
Scenario: user clicks a button in your ASP.NET page and you want to disable it immediately using javascript so that the user cannot accidentally click it again. Originally I thought this was going to be simple by using the onclientclick property of the...
Credit Card Expiration Date DropDownList Sample Code
The other day I needed to create a credit card input form including the drop down lists for the credit card expiration month and year.  I started to write the code to populate the month and year drop down lists and I wanted to make them dynamic so...
nvarchar(max) parameters need the size set to -1
SQL Server 2005 supports a new data type nvarchar(max). This is one of the new max datatypes that are to replace ntext, text, and image in a future version of SQL Server (according to SQL Server Books Online) but you should start using them now. I recently...
More Posts

Search

Go

This Blog

News

Syndication