2012-05-08 15 views

Respuesta

11

marca de Gracias, que era muy útil. Lo que realmente quería preguntar era "cómo obtener" defaultRedirect "propiedad de la sección customErrors desde web.config de mi aplicación asp mvc?".

Y la respuesta, sobre la base de su puesto es:

CustomErrorsSection customErrorsSection = (CustomErrorsSection) ConfigurationManager.GetSection("system.web/customErrors"); 
     string defaultRedirect = customErrorsSection.DefaultRedirect; 
12

Si entiendo bien su pregunta, esto debería ayudar (copiado de MSDN)

// Get the Web application configuration. 
Configuration configuration = WebConfigurationManager.OpenWebConfiguration("/aspnetTest"); 

// Get the section. 
CustomErrorsSection customErrorsSection = (CustomErrorsSection)configuration.GetSection("system.web/customErrors"); 

// Get the collection 
CustomErrorCollection customErrorsCollection = customErrorsSection.Errors; 

// Get the currentDefaultRedirect 
string currentDefaultRedirect = customErrorsSection.DefaultRedirect; 
Cuestiones relacionadas