问题
我在启动单元测试时遇到了严重的延迟(几分钟),如果我正在调试它似乎并不重要.
在调试时我可以在输出窗口中看到有一个包被重复加载和重新卸载.这种情况发生了数千次.
'vstest.executionengine.x86.exe' (CLR v4.0.30319: Domain 929): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'vstest.executionengine.x86.exe' (CLR v4.0.30319: Dependency finder domain): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.QualityTools.Tips.UnitTest.AssemblyResolver\12.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.QualityTools.Tips.UnitTest.AssemblyResolver.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'vstest.executionengine.x86.exe' (CLR v4.0.30319: Dependency finder domain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'vstest.executionengine.x86.exe' (CLR v4.0.30319: Dependency finder domain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll'. Skipped …Run Code Online (Sandbox Code Playgroud) 在我的控制器中,我想指定一个不同于默认值的视图.像这样 :
public ActionResult EditSurvey(Int32 id)
{
Survey survey = _entities.Surveys.Single(s => s.Id == id);
return View("Survey",survey);
}
Run Code Online (Sandbox Code Playgroud)
但是我没有将视图指定为字符串("Survey"),而是想直接引用它,所以如果我决定稍后更改我的视图名称,则不必手动更改此字符串.
所以我正在寻找这样的东西:
public ActionResult EditSurvey(Int32 id)
{
Survey survey = _entities.Surveys.Single(s => s.Id == id);
return View(Views.Admin.Survey,survey);
}
Run Code Online (Sandbox Code Playgroud) 我正在使用服务器验证,并希望在无效时更改元素类.例如,我有一个带验证消息的文本框:
@Html.ValidationMessageFor(m => m.FirstName, new {@class = "error"})
@Html.TextBoxFor(m => m.FirstName, new {@class = "aftererror"})
Run Code Online (Sandbox Code Playgroud)
当文本框数据无效时,我希望文本框获得红色边框.我尝试使用css选择器更改它:
.error + .aftererror
{
border:solid 1px red;
}
Run Code Online (Sandbox Code Playgroud)
因此,当验证消息显示时,文本框将获得"aftererror"类.不幸的是,即使数据有效,验证元素也会显示,只有没有文本.
那么如何在出错时更改texbox的css类,或者在没有错误时让验证元素消失.
当我尝试在IIS7上部署我的MVC3应用程序时,在每个URL上我得到一个Http 500 - 内部服务器错误.
该站点在Visual Studio中的开发中运行良好.我可以请求简单的html页面或aspx页面,它们返回正常.我已经通过添加一个返回内联<%= DateTime.Now.ToShortDateString()%>的aspx页面来测试asp.net是否正常工作,这也可以正常工作.所以我认为问题在于MVC本身或路由.
MVC3安装在服务器上,但我也通过设置所有与MVC相关的引用来尝试bin部署copy local = true.
有任何想法吗 ?
编辑:
我启用了失败的请求跟踪,这导致没有错误日志.
客户错误已关闭且服务器错误详细:
<httpErrors errorMode="Detailed" />
<asp scriptErrorSentToBrowser="true"/>
<customErrors mode="Off"/>
Run Code Online (Sandbox Code Playgroud)
我唯一得到的是一个带有空白页面的500 - 内部服务器错误标题.
我检查了网络服务器的事件日志,没有找到.
一些重新启动后,我得到一个更详细的错误:

我一直在尝试通过Sitecore编辑器中已更改的代码发布项目.如果我以编程方式更新字段值并发布这些更改,它可以正常工作.
我们的内容管理编辑经常在编辑器中进行更改,而不必发布它们.我们希望为他们提供一种功能,可以单击一个按钮来发布所有相关更改并清除Sitecore缓存.
我不想发布整个网站,只发布几个预定义的项目.
我们目前正在使用Sitecore.NET 6.4.1(rev.110720).我无法更新Sitecore.
我试过这些选项:
选项1:实例化新的发布者对象
Database master = Sitecore.Configuration.Factory.GetDatabase("master");
Database web = Sitecore.Configuration.Factory.GetDatabase("web");
Sitecore.Publishing.PublishOptions publishOptions = new Sitecore.Publishing.PublishOptions(master,
web,
Sitecore.Publishing.PublishMode.SingleItem,
item.Language,
System.DateTime.Now);
Sitecore.Publishing.Publisher publisher = new Sitecore.Publishing.Publisher(publishOptions);
publisher.Options.RootItem = item;
publisher.Options.Deep = true;
publisher.Publish();
Run Code Online (Sandbox Code Playgroud)
选项2:使用静态发布管理器
Database db = Sitecore.Configuration.Factory.GetDatabase("web");
Database[] databases = new Database[1] { db };
Sitecore.Handle publishHandle = Sitecore.Publishing.PublishManager.PublishItem(item, databases, db.Languages, true, false);
Run Code Online (Sandbox Code Playgroud)
这两种方法都包含在using语句中,以使用内容管理编辑器使用的同一帐户.
string domainUser = @"sitecore\admin";
if (Sitecore.Security.Accounts.User.Exists(domainUser))
{
Sitecore.Security.Accounts.User user =
Sitecore.Security.Accounts.User.FromName(domainUser, false);
using (new Sitecore.Security.Accounts.UserSwitcher(user))
{
// publish code ...
}
} …Run Code Online (Sandbox Code Playgroud) .net ×2
c# ×2
asp.net ×1
asp.net-mvc ×1
deployment ×1
sitecore ×1
sitecore6 ×1
t4mvc ×1
unit-testing ×1