我试着RoleEnvironment.GetConfigurationSetting("SOMEKEY")像这样打电话:
public partial class AzureBasePage : System.Web.UI.Page
{
protected ChargifyConnect Chargify
{
get {
if (this._chargify == null) {
this._chargify = new ChargifyConnect();
this._chargify.apiKey = RoleEnvironment.GetConfigurationSettingValue("CHARGIFY_API_KEY");
}
return this._chargify;
}
}
private ChargifyConnect _chargify = null;
}
Run Code Online (Sandbox Code Playgroud)
我的ServiceConfiguration.cscfg键如下所示:
<Setting name="CHARGIFY_API_KEY" value="AbCdEfGhIjKlMnOp" />
Run Code Online (Sandbox Code Playgroud)
我收到这个错误:
异常详细信息:System.Runtime.InteropServices.SEHException:外部组件引发了异常.
[SEHException(0X80004005):外部组件引发的异常.] RoleEnvironmentGetConfigurationSettingValueW(UINT16*,UINT16*,UInt32的,UInt32的*)0 Microsoft.WindowsAzure.ServiceRuntime.Internal.InteropRoleManager.GetConfigurationSetting(字符串名称,字符串&RET)92微软.WindowsAzure.ServiceRuntime.RoleEnvironment.GetConfigurationSettingValue(字符串configurationSettingName)67 ChargifyNET.ChargifyAzurePage.get_Chargify()在C:\ NetProjects\ChargifyDotNET \源\ Chargify.NET\ChargifyAzurePage.cs:26 Chargify.Azure._Default.Page_Load(对象发件人,EventArgs e)在C:\ NetProjects\ChargifyDotNET\Source\Chargify.Azure\Default.aspx.vb:8 System.Web.UI.Control.OnLoad(EventArgs e)+99 System.Web.UI.Control.LoadRecursive( )+50 System.Web.UI.Page.ProcessRequestMain(布尔includeStagesBeforeAsyncPoint,布尔includeStagesAfterAsyncPoint)+627
MVC 3中的默认验证基于jQuery验证,我通常可以使用以下内容进行自定义:
$.validator.setDefaults({
submitHandler: function() { alert('submitHandler'); },
errorPlacement: function(error, element) {
// do something important here
alert('errorPlacement');
},
errorClass: "error",
errorElement: "input",
onkeyup: false,
onclick: false
})
Run Code Online (Sandbox Code Playgroud)
但是,这似乎在MVC 3中不起作用.具体来说,似乎并没有调用errorPlacement,我也不知道为什么.我将调用submitHandler,但绝不会调用errorPlacement.
如何自定义验证以匹配我的网站风格所需的任何结构/样式?默认值很高,但并不总是适用于所有情况.
我最近遇到了试图使用MvcSiteMapProvider的路障.
在我的申请中,我有三个不同的领域:着陆,应用和管理.我目前已经实现了MvcSiteMapProvider并且它的工作效果令人惊讶,但我现在要做的是 - 使用Html MvcSiteMap Helper并根据我所在的区域指定不同的地图提供者.
所以,当我:
我尝试过以下方法:
共享 - > _AppLayout.cshtml
@Html.Partial("_Menu")
Run Code Online (Sandbox Code Playgroud)
共享 - > _Menu.cshtml
@{
if (HttpContext.Current != null && HttpContext.Current.Handler is System.Web.Mvc.MvcHandler)
{
var handler = HttpContext.Current.Handler as System.Web.Mvc.MvcHandler;
var currentArea = handler.RequestContext.RouteData.Values["area"] ?? string.Empty;
if (!string.IsNullOrEmpty(currentArea.ToString()))
{
<text>@Html.MvcSiteMap("AppSiteMapProvider").Menu()</text>
}
else if (currentArea.ToString() == "Admin")
{
<text>@Html.MvcSiteMap("AdminSiteMapProvider").Menu()</text>
}
}
Run Code Online (Sandbox Code Playgroud)
}
有什么建议?我不想将_AppLayout.cshtml内容复制/粘贴到一个区域的新主服务器中,我宁愿它动态地选择正确的提供程序.