Asp.net 标识符期望从web.config获取值

Asp.net 标识符期望从web.config获取值,asp.net,vb.net,Asp.net,Vb.net,我正在从web.config读取值,并希望将web.config中的url重定向给用户。但是,当我试图访问密钥时,这给了我一个预期标识符的错误。下面是我的web.config和代码部分。你能解释一下我在这里犯了什么错误吗 <appSettings> <add key="SECURE_URL" value="https://google.com"/> </appSettings> 当您使用VB.NET时,您不使用方括号([“SECURE_URL

我正在从web.config读取值,并希望将web.config中的url重定向给用户。但是,当我试图访问密钥时,这给了我一个
预期标识符的错误。下面是我的web.config和代码部分。你能解释一下我在这里犯了什么错误吗

<appSettings>  
    <add key="SECURE_URL" value="https://google.com"/>
  </appSettings>

当您使用VB.NET时,您不使用方括号([“SECURE_URL”])来访问索引,而是使用普通括号((“SECURE_URL”)),因此您需要更改以下行

Dim StrValue As String  = System.Configuration.ConfigurationManager.AppSettings["SECURE_URL"]
Response.Redirect("StrValue" + "/park/notice/payment.aspx")
进入

这将解决编译器错误;但是,为了使您的示例生效,您还应该更改以下行

Dim StrValue As String  = System.Configuration.ConfigurationManager.AppSettings["SECURE_URL"]
Response.Redirect("StrValue" + "/park/notice/payment.aspx")

这样,将使用
StrValue
的值。
此外,在使用其值之前,应检查
StrValue
是否为Nothing(null)或空,即:

If Not String.IsNullOrEmpty(StrValue) Then
    Response.Redirect(StrValue + "/park/notice/payment.aspx")
End If

当您使用VB.NET时,您不使用方括号([“SECURE_URL”])来访问索引,而是使用普通括号((“SECURE_URL”)),因此您需要更改以下行

Dim StrValue As String  = System.Configuration.ConfigurationManager.AppSettings["SECURE_URL"]
Response.Redirect("StrValue" + "/park/notice/payment.aspx")
进入

这将解决编译器错误;但是,为了使您的示例生效,您还应该更改以下行

Dim StrValue As String  = System.Configuration.ConfigurationManager.AppSettings["SECURE_URL"]
Response.Redirect("StrValue" + "/park/notice/payment.aspx")

这样,将使用
StrValue
的值。
此外,在使用其值之前,应检查
StrValue
是否为Nothing(null)或空,即:

If Not String.IsNullOrEmpty(StrValue) Then
    Response.Redirect(StrValue + "/park/notice/payment.aspx")
End If

我在这部分中遇到错误`Dim StrValue As String=System.Configuration.ConfigurationManager.AppSettings[“SECURE_URL”]`关于identifer@Abhishek:是否已添加对System.configuration程序集的引用?这是编译器错误还是异常?我添加了
System.configuration assembly
,但不知道为什么会出现这种情况this@Abhishek:我已经更新了样本;我认为错误就在你使用的括号中。谢谢一个小错误让我非常感谢你,所以我在这部分中遇到了错误`Dim StrValue As String=System.Configuration.ConfigurationManager.AppSettings[“SECURE_URL”]`关于identifer@Abhishek:是否已添加对System.configuration程序集的引用?这是编译器错误还是异常?我添加了
System.configuration assembly
,但不知道为什么会出现这种情况this@Abhishek:我已经更新了样本;我想错误就在你用的括号里。谢谢一个小错误让我非常非常感谢你