I've been finding a code in C# asp.net for a 404 error how do I create a 404 error that works significantly everytime whenever a page does not exist?
Asked
Active
Viewed 3,815 times
-2
-
5Welcome to Stack Overflow. Your question seems doesn't fit here. Did you try anything so far? Show your effort first so people might show theirs. Please read [FAQ] and [ask] – Soner Gönül Feb 02 '14 at 14:17
-
1Please read how to ask question first – Saleh Parsa Feb 02 '14 at 14:19
-
Do you means something in UI or backend ?. The only thing you need to care is result the response with code 404. Look at this http://stackoverflow.com/questions/667053/best-way-to-implement-a-404-in-asp-net – Anirudha Gupta Feb 02 '14 at 14:19
-
can you just tell me a code or something please? – Moosa Zaidi Feb 02 '14 at 14:22
-
like I created a page Contact.aspx and if somebody by mistake opens Contactme.aspx I want to generate a 404 error page how can I do that any code? – Moosa Zaidi Feb 02 '14 at 14:23
-
Hussam Hussien thank you but it's still giving me an error – Moosa Zaidi Feb 02 '14 at 14:26
-
@AliMoosa Sorry, this is not a site to get your homework done. We dont just provide you with some code solution. Ask a good question, then you might get a good answer. – Uli Köhler Feb 02 '14 at 14:46
-
Sorry it's just that I'm new to programming :'| – Moosa Zaidi Feb 02 '14 at 14:50
1 Answers
1
create your custome 404.aspx page and you have to put this in your web config before the final configuration tag
<configuration>
<system.web>
<customErrors defaultRedirect="404.aspx" mode="On" >
<error statusCode="404" redirect="404.aspx"/>
</customErrors>
</system.web>
</configuration>
that's all :)

Hussam Hussien
- 49
- 3