Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 在mvc视图中使用带字符串的appsetting键_Asp.net_Asp.net Mvc_Asp.net Mvc 4 - Fatal编程技术网

Asp.net 在mvc视图中使用带字符串的appsetting键

Asp.net 在mvc视图中使用带字符串的appsetting键,asp.net,asp.net-mvc,asp.net-mvc-4,Asp.net,Asp.net Mvc,Asp.net Mvc 4,我试图在MVC视图中分配appsetting键值+字符串 我尝试了@System.Configuration.ConfigurationManager.AppSettings[myKey].ToString+Custom/CustomerProfile.aspx,但没有成功 <a href="here..." id="doneLink" class="btn btn-primary">Done</a> 在代码周围加括号,使其成为显式表达式: <a href=

我试图在MVC视图中分配appsetting键值+字符串

我尝试了@System.Configuration.ConfigurationManager.AppSettings[myKey].ToString+Custom/CustomerProfile.aspx,但没有成功

   <a href="here..." id="doneLink" class="btn btn-primary">Done</a>

在代码周围加括号,使其成为显式表达式:

<a href="@(
    System.Configuration.ConfigurationManager.AppSettings["myKey"].ToString()+"Custom/CustomerProfile.aspx"
)" id="doneLink" class="btn btn-primary">Done</a>
以下是Phil Haack提供的方便快捷的参考资料:


在代码周围加括号,使其成为显式表达式:

<a href="@(
    System.Configuration.ConfigurationManager.AppSettings["myKey"].ToString()+"Custom/CustomerProfile.aspx"
)" id="doneLink" class="btn btn-primary">Done</a>
以下是Phil Haack提供的方便快捷的参考资料:


这对我有用。您得到的具体错误是什么

<a href="@System.Configuration.ConfigurationManager.AppSettings["key"]" />

这对我有用。您得到的具体错误是什么

<a href="@System.Configuration.ConfigurationManager.AppSettings["key"]" />

假设您希望在链接的href属性中使用该字符串,我会这样做:

@{
  var href = System.Configuration.ConfigurationManager.AppSettings["myKey"].ToString() + "Custom/CustomerProfile.aspx";
}

<a href="@href" id="doneLink" class="btn btn-primary">Done</a>

但是,看起来您没有使用Razor,因为您的链接以.aspx而不是.cshtml结尾。是这样吗?

假设您希望在链接的href属性中使用该字符串,我会这样做:

@{
  var href = System.Configuration.ConfigurationManager.AppSettings["myKey"].ToString() + "Custom/CustomerProfile.aspx";
}

<a href="@href" id="doneLink" class="btn btn-primary">Done</a>

但是,看起来您没有使用Razor,因为您的链接以.aspx而不是.cshtml结尾。是吗?

你的问题不是很清楚。是否要在标记的href属性中使用该连接字符串?顺便说一句,您的链接以.aspx结尾,因此看起来您没有使用Razor。是吗?你的问题不是很清楚。是否要在标记的href属性中使用该连接字符串?顺便说一句,您的链接以.aspx结尾,因此看起来您没有使用Razor。是这样吗?