Tag: asp.net mvc

ASP.NET MVC计算运费总计

如何用razor html计算运费总额。 第一件商品的运费为3.99美元,每件商品的运费为0.99美元。 @{ double itemTotal = 0; double subTotal = 0; int totalQty = 0; double discount = 0.8; double shippingBase = 3.99; double shippingItem = 0.99; } @foreach (var item in Model) { double price = (double)item.price / 100 * discount; itemTotal = @item.qty * price; subTotal += itemTotal; totalQty += @item.qty;

如何在我的自定义表而不是aspnet用户中使用哈希密码保存新记录?

我使用asp.net身份创建新用户但收到错误: 无法将值NULL插入列’Id’,表’Mydb.dbo.AspNetUsers’; 列不允许空值。 INSERT失败。\ r \ n语句已终止 但是在这里我没有像AspNetUsers这样的表,而是我拥有自己的用户表。 代码: Web.config:2个连接字符串 IdentityModel.cs: public class ApplicationUser : IdentityUser { public async Task GenerateUserIdentityAsync(UserManager manager) { // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType this.SecurityStamp = Guid.NewGuid().ToString(); var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie); // Add custom user claims here return userIdentity; } public string Id […]

LINQ to Entities无法识别方法’System.String get_Item(System.String)’,

我怎么解决这个问题? 这是我的代码: DateTime dtInicio = new DateTime(); DateTime dtFim = new DateTime(); Int32 codStatus = 0; if(!string.IsNullOrEmpty(collection[“txtDtInicial”])) dtInicio = Convert.ToDateTime(collection[“txtDtInicial”]); if(!string.IsNullOrEmpty(collection[“txtDtFinal”])) dtFim = Convert.ToDateTime(collection[“txtDtFinal”]); if (!string.IsNullOrEmpty(collection[“StatusCliente”])) Convert.ToInt32(collection[“StatusCliente”]); var listCLientResult = (from c in db.tbClientes orderby c.id where (c.effdt >= dtInicio || string.IsNullOrEmpty(collection[“txtDtInicial”]) && (c.effdt <= dtFim || string.IsNullOrEmpty(collection["txtDtFinal"])) && (c.cod_status_viagem == codStatus || string.IsNullOrEmpty(collection["StatusCliente"]))) select […]

你如何命名你的ViewModel类?

什么样的命名约定适合ViewModel类? 示例:对于HomeController,索引视图? HomeIndexViewModel似乎不对。

发布使用python脚本的MVC应用程序

我目前有通过Process调用python脚本的MVC项目(新的processStartinfo(“/ path / to / python.exe”,“/ path / to / scripts.py”)。这在visual studio中运行得非常好。当我发布这个时在azure上如何能够调用python.exe?(我可能没有准确地构建这个问题,因为这是我第一个发布的网页,并且没有完全理解发布) PS我确实尝试使用IronPython,但由于我的脚本使用NLTK,我遇到了一堆问题所以用pip安装python&nltk比较容易,然后通过带有/ path / to / script参数的命令行调用python.exe。 PY。 任何输入都表示赞赏。 编辑:我的homeController启动一个进程,它将path_of_python,path_of_script传递给命令行,重定向输出并对它返回的数据(从输出)进行处理。

file()在asp.net mvc中关闭流吗?

我想知道你是否做了类似的事情 public FileResult result() { Stream stream = new Stream(); return File(stream,”text/html”,”bob.html”); } 如果File()会关闭你的流? 因为我试图将“stream”放在using语句中,但它总是给我一个错误,说流已关闭。 public FileResult result() { using(Stream stream = new Stream()) { return File(stream,”text/html”,”bob.html”); } }

如何自动化(映射子成员)

我有类似的东西 public class ProductViewModel { public int SelectedProductId { get; set; } public string ProductName {get; set;} public int Qty {get; set;} public List Products { get; set}; } 我有这样的域名 public class Product { public int ProductId {get; set;} public string ProductName {get; set;} public int Qty {get; set;} } public class Store { public […]

如何在c#代码中使用MVC 3 @ Html.ActionLink

我想在ac#函数中调用@ Html.ActionLink方法来返回一个带有链接的字符串。 像这样的东西: string a = “Email is locked, click ” + @Html.ActionLink(“here to unlock.”, “unlock”) ;

如何在MVC中创建动态子域?

我已将我的网站托管为www.sample.com,但我需要 -user1.sample.com -user2.sample.com -user3.sample.com 可能吗? 每个用户作为子域名。

将参数传递给jsonresult的actionresult

我编写代码来过滤结果如下图, 一旦它过滤后我想将以下字段的模型值作为参数发送到另一个控制器方法,我可以在单击Generate Report按钮后调用该方法 这是视图文件 @model project_name.Models.SearchVM …. @using (Html.BeginForm()) { @Html.AntiForgeryToken() @Html.ValidationSummary(true, “”, new { @class = “text-danger” }) …. @Html.LabelFor(m => m.Type, htmlAttributes: new { @class = “control-label col-md-2” }) @Html.DropDownListFor(m => m.Type, Model.TypeList, “Select the type”, new { @class = “form-control” }) @Html.ValidationMessageFor(model => model.Type, “”, new { @class = “text-danger” }) …………… […]