---
title: "Hämta CustomError url från web.config"
type: "forum-thread"
url: "https://www.webforum.nu/amne/dotnet/189138-hämta-customerror-url-från-web-config"
topic: ".NET"
topic_url: "https://www.webforum.nu/amne/dotnet"
author: "doggelito"
published: "2012-02-14T16:11:05.000Z"
updated: "2012-02-14T16:33:42.000Z"
replies: 1
views: 403
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/dotnet/189138-hämta-customerror-url-från-web-config"
---

# Hämta CustomError url från web.config

## #1 — doggelito, 2012-02-14T16:11Z

Hej, 
Jag har denna i web.config:

```
<customErrors mode="On">
      <error statusCode="403" redirect="/error/http403"/>
      <error statusCode="404" redirect="/error/http404"/>
      <error statusCode="500" redirect="/error/general"/>
</customErrors>
```

Nu skulle jag vilja kunna hämta upp error 500:s url i en sträng. 
Nån som har en susning om hur jag kan göra det?
Typ:

```
string url = Configuration.CustomErrors.GetError("500").Url;
```

Permalänk: https://www.webforum.nu/p/189138

## #2 — doggelito, 2012-02-14T16:33Z

Hitta på:t :)

```
System.Configuration.Configuration configuration = WebConfigurationManager.OpenWebConfiguration("~");
CustomErrorsSection customErrorsSection = (CustomErrorsSection)configuration.GetSection("system.web/customErrors");
CustomErrorCollection customErrorsCollection = customErrorsSection.Errors;

string url = customErrorsCollection["500"].Redirect;
```

Permalänk: https://www.webforum.nu/p/2292519

---

Tråden på webben: https://www.webforum.nu/amne/dotnet/189138-hämta-customerror-url-från-web-config
