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 implement ISNULL(SUM(ColumnName),0) in Linq2SQL
I had a Linq2Sql statement like this: var q = from o in db.OrderItem where o.UserId == UserId select o.Amount; And then I was trying to get the sum of the OrderItem.Amount column by doing this: total = q.Sum(); This worked fine as long as there were rows...
Linq2Sql: How to join tables on more than one column
You can join two tables in Linq2Sql by using an anonymous type to specify the join.  var r =     from o in db.Orders     join p in db.Products on o.ProductId equals p.ProductId     join pu in db.ProductUsers...
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...
How to get an indexed item of an IEnumerable object (Linq)
If you have an IEnumerable<T> collection of some objects T and you need to get a particular item out of that collection, you cannot use the standard indexing that you would normally use with brackets ([index]).  If you try you will get an error...
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.   ...
GDI+ Error when converting Tiff to Jpeg: Parameter is not valid
One of the web applications that I work on is Instant Church Directory , a website that helps churches create a church photo directory .  Since the main focus of the application is to create a photo directory, customers are uploading all sorts of...
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...
How to quickly format a C# class file – Ctrl-K, Ctrl-D
In C# as you are typing in a class file the indenting of your code can easily get out of alignment making the code hard to read.  Where does your class, if block, or method begin and end?? You can manually go and fix each line but there is a much...
More Posts Next page »

Search

Go

This Blog

News

Syndication