- Recent
- Popular
- Tags (0)
- Subscribers (9)
- How to respond with code 404 (Not Found) in ASP.NETAugust 26
-
Suppose you configured custom 404 page in web.config file in the customErrors section. So whenever user requests non-existent aspx page, ASP.NET run-time returns well formatted message to the user.
Also you have a page that shows articles from a database according to article ID passed in the url (for example: article.aspx?id=345). But if user passes article ID that doesn't exists the page must return code 404 (Not Found) and show the custom 404 page like in the previous situation.
Fortunately you don't need to parse the customErrors section to get name of the custom 404 page. Just throw HttpException:
throw new HttpException(404, "Article not found");
ASP.NET run-time will catch the exception and will redirect to the custom 404.
- Code snippets for some common operations with exceptionsMay 19
-
Download and install these additional code snippets for common operations with exceptions. To use them type shortcut for the code snippet that you want to add to your code and then type Tab, Tab to invoke it.
- News: .NET Tips & Tricks Community RSSMay 10
-
Those who prefer reading this site through RSS now can also subscribe for updates to .NET Tips & Tricks Community.
- Send an e-mail any time an unhandled exception occursMay 10
-
Consider using built-in ASP.NET health monitoring to monitor your website. Especially if you are not monitoring it at all yet. ASP.NET health monitoring contains ready-to-use Web health-monitoring events classes (Web events) and health-monitoring providers (listeners). For example, you can easily configure it to send an email any time an error is detected.
- News: Why does new tips appear on this site so infrequently?May 7
-
Hi guys. I know some of you are not satisfied with the frequency new tips appear on this site. The last comment I received was a proposal to rename the site to .NET Tip of The Month :) But I don't want to do this because I'm going to fix this problem. I'm working on the .NET Tips & Tricks Community section now. My tips that are too small to hit the front page were added to this section. It's the place where all of you can share your .NET tips and tricks.
It's clear that this section lacks for some features. And if anyone out of 2510 subscribers has a proposal, just drop me a line. My email is kostya.ly@gmail.com.
Thanks for you patience.
Kostya Ly
