我有一个具有4个属性的模型,其类型为字符串.我知道您可以使用StringLength注释验证单个属性的长度.但是,我想验证4个属性组合的长度.
使用数据注释执行此操作的MVC方式是什么?
我问这个是因为我是MVC的新手,并希望在制作我自己的解决方案之前以正确的方式做到这一点.
我安装了Visual Studio 2015 RC并在其上安装了Visual Studio 2015 RTM.我在互联网上找不到任何说你不能这样做的东西.我不知道这是否与问题有关.
不幸的是,当我在重新启动后第一次启动VS 2015 RTM时弹出消息框:
"'Microsoft.VisualStudio.Editor.Implementation.EditorPackage'包未正确加载"
也:
我该如何解决这个错误?
它说要查看ActivityLog.xml.我找不到Microsoft.VisualStudio.Editor.Implementation.EditorPackage.
但对于XamarinShellPackage,它说:
<entry>
<record>339</record>
<time>2015/07/21 13:01:54.011</time>
<type>Error</type>
<source>VisualStudio</source>
<description>SetSite failed for package [XamarinShellPackage]</description>
<guid>{2D510815-1C4E-4210-BD82-3D9D2C56C140}</guid>
<hr>80070057 - E_INVALIDARG</hr>
<errorinfo>'providers' cannot contain a null (Nothing in Visual Basic) element.
Parameter name: providers</errorinfo>
</entry>
<entry>
<record>340</record>
<time>2015/07/21 13:01:54.013</time>
<type>Error</type>
<source>VisualStudio</source>
<description>End package load [XamarinShellPackage]</description>
<guid>{2D510815-1C4E-4210-BD82-3D9D2C56C140}</guid>
<hr>80070057 - E_INVALIDARG</hr>
<errorinfo>'providers' cannot contain a null (Nothing in Visual Basic) element.
Parameter name: …Run Code Online (Sandbox Code Playgroud) 我有一个带有图像链接的网格(Infragistics JQuery网格)的视图(Index.cshtml).如果用户单击此链接,将调用以下jquery函数:
function ConfirmSettingEnddateRemarkToYesterday(remarkID) {
//Some code...
//Call to action.
$.post("Home/SetEnddateRemarkToYesterday", { remarkID: remarkID }, function (result) {
//alert('Succes: ' + remarkID);
//window.location.reload();
//$('#remarksgrid').html(result);
});
}
Run Code Online (Sandbox Code Playgroud)
注释掉你可以看到我自己的警报和2次刷新视图的尝试.location.reload()有效,但对于浏览器来说基本上是太多了..html(result)在remarksgrid div中发布整个index.cshtml + Layout.cshtml double.所以这是不正确的.
这是它调用的动作(SetEnddateRemarkToY yesterday):
public ActionResult SetEnddateRemarkToYesterday(int remarkID) {
//Some logic to persist the change to DB.
return RedirectToAction("Index");
}
Run Code Online (Sandbox Code Playgroud)
这是它重定向到的操作:
[HttpGet]
public ActionResult Index() {
//Some code to retrieve updated remarks.
//Remarks is pseudo for List<Of Remark>
return View(Remarks);
}
Run Code Online (Sandbox Code Playgroud)
如果我在成功的AJAX帖子之后没有执行window.location.reload,那么视图将永远不会重新加载.我是MVC的新手,但我确信有更好的方法可以做到这一点.我不是在理解一些基本的东西.也许正朝着正确的方向努力?先感谢您.
我有一个用C#.NET编写的DLL,它暴露了一个COM接口,所以一个vb6应用程序可以调用我的DLL.此界面如下所示:
[System.Runtime.InteropServices.Guid("3D2C106C-097F-4ED7-9E4F-CDBC6A43BDC4")]
public interface IZDPharmaManager {
[System.Runtime.InteropServices.DispId(2)]
SearchPatientEventArgs FoundPatient { get; set; }
[System.Runtime.InteropServices.DispId(3)]
IntPtr Start(string server, string database, string user, string password, bool integrated, int praktijkID, string userGUID, int userID, string userName, bool hasRightToSearchPatient);
[System.Runtime.InteropServices.DispId(4)]
void Stop();
[System.Runtime.InteropServices.DispId(5)]
void InitializeSkinner(System.Object skinnerFramework);
}
[System.Runtime.InteropServices.Guid("4438852E-CF2D-4DB0-8E6E-428F65A6B16C")]
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface IZDPharmaManagerEvents {
[DispId(1)]
void SearchPatient(ZDPharmaManager sender, SearchPatientEventArgs e);
}
[System.Runtime.InteropServices.Guid("9297D43F-C581-3F0F-AA60-9506C6B77B5F")]
[ClassInterface(ClassInterfaceType.None)]
public class SearchPatientEventArgs : WebHIS.ZDPharmaceutisch.ISearchPatientEventArgs {
public SearchPatientEventArgs() {
//Nodig voor COM.
}
public int ID { get; set; }
public string …Run Code Online (Sandbox Code Playgroud) 我的Redshift群集位于私有VPC中.我在Node.js中写了以下AWS Lamba,它应该连接到Redshift(为这个问题打扮):
'use strict';
console.log('Loading function');
const pg = require('pg');
exports.handler = (event, context, callback) => {
var client = new pg.Client({
user: 'myuser',
database: 'mydatabase',
password: 'mypassword',
port: 5439,
host: 'myhost.eu-west-1.redshift.amazonaws.com'
});
// connect to our database
console.log('Connecting...');
client.connect(function (err) {
if (err) throw err;
console.log('CONNECTED!!!');
});
};
Run Code Online (Sandbox Code Playgroud)
不幸的是,我一直在60.00秒后让任务超时.我在日志" 连接... "中看到,但从未" 连接!!! ".
我到目前为止采取的步骤是为了让它发挥作用:
经过一些好的测试后,BIG更新
我有一个MVC4 Web应用程序,我只是在visual studio 2010中调试它,只是为了更多地了解webdevelopment(特别是MVC).我现在正在玩Session.但是我不明白为什么在新的httprequest之后我丢失了变量.
就像这个问题:丢失我的会话变量
我对会话部分的web.config看起来像:
<sessionState mode="InProc"
cookieless="false"
timeout="20"/>
Run Code Online (Sandbox Code Playgroud)
我的小测试项目隔离问题工作正常,看起来像:
控制器 - HomeController
public class HomeController : Controller
{
//
// GET: /Test/
public ActionResult Index()
{
string t = (string)Session["Test1"];
ViewBag.Result = t;
return View();
}
}
Run Code Online (Sandbox Code Playgroud)
MysessionController
public class MysessionController:Controller {// // GET:/ Mysession /
public ActionResult Index()
{
return View(new Models.Mysession() {ID = Session.SessionID});
}
[HttpPost]
public ActionResult Index(Models.Mysession mySession) {
Session["Test1"] = "Bla";
return RedirectToAction("Index", "Home");
}
}
Run Code Online (Sandbox Code Playgroud)楷模
public class Mysession { …Run Code Online (Sandbox Code Playgroud)