Læs fra web.config
Jeg har i lang tid prøvet på at læse fra web.config - uden held! Arrgh..Min web.config fil:
<configuration>
<appSettings>
<add key="mssql" value="min dsn streng.."/>
</appSettings>
<system.web>
<compilation debug="true"/>
<customErrors mode="RemoteOnly" defaultRedirect="pub/fejl.aspx">
<error statusCode="403" redirect="pub/fejl.aspx?fejl=403"/>
<error statusCode="404" redirect="pub/fejl.aspx?fejl=404"/>
<error statusCode="500" redirect="pub/fejl.aspx?fejl=500"/>
</customErrors>
<globalization fileEncoding="ISO-8859-1"/>
</system.web>
</configuration>
Jeg prøver så at hente den på følgende måde..:
<script language="VB" runat="server">
Sub Page_Load(Sender As Object, E As EventArgs)
Dim Context as HttpContext = HttpContext.Current
Dim AppSettings as Hashtable = Context.GetConfig("appSettings")
Dim DSN = AppSettings("mssql")
Response.Write(DSN)
End sub
</script>
Men jeg får fejlen "Specified cast is not valid." ved linjen Dim AppSettings... Hvad går der galt?
