目前我已经设置了一个Web部署项目,它将代码编译到该.\Release文件夹中.在构建之后,我想将文件复制到另一台机器上(因为您构建的任何目录都被删除然后重新创建).
用于定义要复制的文件的ItemGroup设置如下:
<ItemGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<ReleaseFiles Include=".\Release\**\*" />
<OverrideFiles Include="..\website\App_Code\override\site.com\**\*" />
</ItemGroup>
Run Code Online (Sandbox Code Playgroud)
"网站"是用于多个站点的代码,因此在解决方案中设置了多个Web部署项目.
然后,我有AfterBuild目标来复制文件:
<Target Name="AfterBuild" Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Copy SourceFiles="@(ReleaseFiles)" ContinueOnError="true" SkipUnchangedFiles="true" DestinationFiles="@(ReleaseFiles->'\\server\web\site.com\%(RecursiveDir)%(Filename)%(Extension)')" />
<Copy SourceFiles="@(OverrideFiles)" DestinationFiles="@(OverrideFiles->'\\server\web\site.com\%(RecursiveDir)%(Filename)%(Extension)')" />
</Target>
Run Code Online (Sandbox Code Playgroud)
但是,ReleaseFiles没有被复制,可能是什么原因造成的?我有错误.\TempBuildDir\folder\subfolder - The process cannot access the file because it is being used by another process.,folder\subfolder每次都可以有所不同,但即使没有出现该消息,文件仍然没有被复制.
问题是,它以前有用过.
我使用LINQ to Entities设置了一个模型,并且代码可以按预期添加到数据库中.但是,当我使用.NET 3.5时,我无法使UpdateModel工作.
[HttpPost]
public ActionResult Edit(Site.Models.XYZ xyz)
{
try
{
var original = db.XYZ.First(u => u.id == xyz.id);
UpdateModel(original);
db.SaveChanges();
return RedirectToAction("Index");
}
catch (Exception ex)
{
return View("Error");
}
}
Run Code Online (Sandbox Code Playgroud)
这导致以下异常:
System.InvalidOperationException was caught
Message=The model of type 'Site.Models.XYZ' could not be updated.
Source=System.Web.Mvc
StackTrace:
at System.Web.Mvc.Controller.UpdateModel[TModel](TModel model, String prefix, String[] includeProperties, String[] excludeProperties, IValueProvider valueProvider)
at System.Web.Mvc.Controller.UpdateModel[TModel](TModel model, String prefix)
at Site.Controllers.XYZController.Edit(Site.Models.XYZ xyz) in D:***.cs:line 81
InnerException:
Run Code Online (Sandbox Code Playgroud)
如果我这样做UpdateModel(xyz),则不会发生异常,但数据也不会保存.
如何让UpdateModel使用它(不更新到.NET 4.0),为什么不能更新(由于没有内部异常,异常没有帮助)?
在Visual Web Developer Express 2008中,SubSonic ASP.NET MVC模板似乎不适用于我添加的新数据库.我删除了Chinook数据库并创建了自己的数据库.我理解Models文件夹中的.tt文件用于生成代码,但它们没有(尽管将ConnectionStringName更改为我在web.config中设置的内容)
右键单击每个.tt文件并选择"运行自定义工具"不会生成任何内容,除了错误消息:
Cannot find custom tool 'TextTemplatingFileGenerator' on this system.
Run Code Online (Sandbox Code Playgroud)
这个工具在哪里保存?CodeTemplates中有.tt文件,它们在您创建新控制器或视图时使用,因此我假设有一个工具可以执行此操作.
使用ASP.NET MVC3,Razor和jQuery Unobtrusive验证(由Microsoft提供的开箱即用).
如何"即时"标记字段,即仅在某些情况下?例如,如果用户处于"发布者"角色,则会出现"发布日期"和"发布"按钮.按下"发布"按钮时需要"发布日期"字段,但在"保存草稿"按钮时则不需要.如果用户不在该角色中,则"发布"按钮不会显示在表单中,因此不需要.
我确信这不是可以开箱即用的东西,客户端(jQuery Validate)和服务器端都需要额外的代码.如果可以的话,如何做到这一点并不明显.
当我在ASP.NET MVC项目中包含log4net时,intellisense停止为母版页,用户控件和页面工作.该文件的第一行有一个红色下划线,并带有以下消息:
ASP.NET运行时错误:无法加载文件或程序集'log4net,Version = 1.2.10.0,Culture = neutral,PublicKeyToken = 1b44e1d426115821'或其依赖项之一.参数不正确.(HRESULT异常:0x80070057(E_INVALIDARG))
知道这是什么原因吗?该项目构建良好,我可以调试和部署它.
如何在ASP.NET MVC 3中使用剃刀视图(用于确定如何布局)生成Word文档或PDF?可能通过使用OpenXML SDK(用于WordprocessingML)或iTextSharp(用于PDF).我想让那些了解HTML的人能够改变生成的Word文档或PDF的外观,而无需编写任何C#代码.
在SQL Server 2005中,如何将用户名的变量用于GRANT或DENY对具有数据库的对象的权限?我试过了:
DECLARE @username varchar(30)
SET @username = 'DOMAIN\UserName'
GRANT SELECT ON [mytable] TO @username
GRANT UPDATE([field one], [field two], [field three]) ON [mytable] TO @username
Run Code Online (Sandbox Code Playgroud)
我明白了Incorrect syntax near '@username',然后我将它包裹在[和]中
GRANT SELECT ON [mytable] TO [@username]
Run Code Online (Sandbox Code Playgroud)
然而,这导致了Cannot find the user '@username', because it does not exist or you do not have permission.如何在不输入每个语句的用户名的情况下执行此操作?我想这样做是为了减少任何拼写错误的机会(这可能导致错误的用户获得权限设置)
如何通过PHP进行Active Directory查找?无需重新编译PHP.PHP版本是5.3
我想从他们的用户名中找到一个人的显示名称.Web服务器是IIS 6,PHP使用FastCGI提供服务.
我得到的用户名是:
$cred = explode('\\',$_SERVER['REMOTE_USER']);
if (count($cred) == 1) array_unshift($cred, "(no domain info - perhaps SSPIOmitDomain is On)");
list($domain, $user) = $cred;
return $user;
Run Code Online (Sandbox Code Playgroud)
那我怎么能找到这个名字呢?例如DoeJ = John Doe
编辑:
试图查找用户,但不知道如何找到"基本DN".无法直接访问Active Directory服务器或具有管理员权限,因此请匿名连接.
<?php
//using ldap bind anonymously
// connect to ldap server
$ldapconn = ldap_connect("example.co.uk")
or die("Could not connect to LDAP server.");
if ($ldapconn) {
// binding anonymously
$ldapbind = ldap_bind($ldapconn);
if ($ldapbind) {
echo "LDAP bind anonymous successful...";
ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION,3);
ldap_set_option($ldapconn, LDAP_OPT_REFERRALS,0);
$dn = "CN=Users"; // also …Run Code Online (Sandbox Code Playgroud) 当我打开文件以解压缩其内容时,出现以下异常。当我在 Windows 资源管理器中选择文件或将鼠标悬停在显示工具提示的文件上时,就会发生这种情况。
System.IO.IOException was unhandled
Message=The process cannot access the file 'D:\Documents\AutoUnZip\Zips\MVCContrib.Extras.release.zip' because it is being used by another process.
Source=mscorlib
StackTrace:
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
at System.IO.File.OpenRead(String path)
at AutoUnzip.SelectFolderForm.w_Changed(Object sender, FileSystemEventArgs e) in D:\Projects\WindowsForms\AutoUnzip\AutoUnzip\SelectFolderForm.cs:line 37
at System.IO.FileSystemWatcher.OnCreated(FileSystemEventArgs e)
at System.IO.FileSystemWatcher.NotifyFileSystemEventArgs(Int32 action, String name)
at …Run Code Online (Sandbox Code Playgroud) 我有一个整数列,可能有一个数字或没有分配给它(即在数据库中为null).如何检查它是否为空?
我试过了
if(data.ColumnName == null)
{
...
}
Run Code Online (Sandbox Code Playgroud)
这也不起作用(因为SubSonic不为ActiveRecord使用可空类型(适用时))
if(data.ColumnName.HasValue)
{
...
}
Run Code Online (Sandbox Code Playgroud)
如果存储在数据库中的值为0,那么这将无济于事:
if(data.ColumnName == 0 /* or 0x000? */)
{
...
}
Run Code Online (Sandbox Code Playgroud)
DateTime字段也可能出现同样的问题.
c# ×3
asp.net-mvc ×2
subsonic ×2
.net ×1
asp.net ×1
intellisense ×1
ioexception ×1
log4net ×1
php ×1
sharpziplib ×1
sql-server ×1
t4 ×1