asp.net-mvc-2

Enable/Disable Enterprise Library logging on production

别说谁变了你拦得住时间么 提交于 2019-12-10 16:47:38
问题 On my production, I don't want to have log entry with severity Verbose (or Debug). I need only the info, error etc. What is the right method to enable and disable logging (the debug entries)? I did some research and one possibility is to use Custom Filter class to enable and disable all logs with severity "verbose". But When deploying application on production, what is the right way to enable and disable? 回答1: You can set your logging level in your config file, that way, should you need it in

How to increase 2MB limit on AJAX JSON response w/ ASP.NET MVC

*爱你&永不变心* 提交于 2019-12-10 16:47:34
问题 I am having problems making an AJAX call when the response is over 2MB. Anything with a response under 2MB works fine. When the response is over 2MB, my "success" method never gets called. My application is ASP.NET MVC2. I am making the call using the jQuery AJAX call: $.ajax({ type: "post", data: ajaxData, url: ajaxUrl, success: updateItems, cache: false }); In my controller, I am using the Json() action result method: public ActionResult GetItems(....) { ... return Json(packet); } When I

ASP.NET MVC Int Array parameter with empty array defaults to {0}

痞子三分冷 提交于 2019-12-10 16:42:06
问题 I have a controller action like: Public ActionResult MyAction(int[] stuff){} I make a JSON request like: $.getJSON(url, { stuff: [] }) When it gets to C# it looks like an array with one element in it, which is zero (i.e. like if I did int[] stuff = {0}; ). Is this new with MVC 2 or .NET 4? It seems to have changed recently, but I haven't found a smoking gun. How can I get around this? This can't possibly be expected behavior, can it? 回答1: I think this is a bug in MVC: // create a vpr with raw

How to protect my site from session fixation?

ぐ巨炮叔叔 提交于 2019-12-10 16:36:34
问题 Currently we are facing a problem regarding session fixation. We do have one site which is secured i.e. Https and there is no authentication for it. It means it has anonymous access. So, we are facing session fixation problem from hacker. Can someone help and guide on this???? 回答1: You should find the information you need here: OWASP - information about Session Fixation Session Fixation Vulnerability in ASP.NET - Session Fixation in ASP.NET 来源: https://stackoverflow.com/questions/15021431/how

How can i set Default value for HiddenFieldFor In Asp.Net MVC

旧巷老猫 提交于 2019-12-10 16:28:45
问题 i am using HiddenFor with model binding which is binding value to it. i want to reset the binded value to zero.How can i do it? i tried this but it is not working... <% foreach (var item in Model ) { %> <%: Html.HiddenFor(model => model.ID,new { @value="0"})%> <% } %> 回答1: You can create your own helper extension for that: public static MvcHtmlString HiddenFor<TModel, TProperty>(this HtmlHelper<TModel> helper, Expression<Func<TModel, TProperty>> expression, object value, object htmlAttributes

datetime2 and ProviderManifestToken in Entity Framework

你。 提交于 2019-12-10 15:34:33
问题 I have an MVC app using Entity Framework and a SQL Server 2008 database. I used the EF wizard to generate my data model. I have a SQL Server table with a standard DateTime column. The EF model is using System.DateTime . But when I try to insert a new record into this table from my application, without specifying a value for this DateTime column, I get the error: The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value. I Googled a bit and found that

jQuery Ajax post - 404 error

杀马特。学长 韩版系。学妹 提交于 2019-12-10 15:27:45
问题 I'm posting to an ActionMethod to retrieve some customer counts. The post works fine from my local machine. When deployed to another server its throwing 404 errors. My post is below. I'm not sure why this has stopped working. var urlStr = "/Items/ItemCount/"; jQuery.ajax({ type: 'POST', dataType: 'json', url: urlStr, async: false, //wait on the result to be returned... success: function (DocData) { window.currentCount = DocData[0]; window.maximumAllowed = DocData[1]; }, cache: false, error:

Need help using entities for ASP.NET MVC 2 framework

∥☆過路亽.° 提交于 2019-12-10 15:25:55
问题 I'm making a site in ASP.NET MVC 2 using C#. I designed a database with a bunch of tables that have many to many relationships, similar to the following: GrandParent - many to many - Parent and Parent - many to many - Child I used the Entity Framework to make all of the entities class and am now working on a function in a repository class which adds a GrandParent. It tries to create Child, add it to a Parent, then add the parent to a GrandParent and then add the GrandParent to the database by

Cannot implicitly convert type 'System.Web.Mvc.RedirectToRouteResult' to 'System.Web.Mvc.JsonResult'

随声附和 提交于 2019-12-10 15:16:55
问题 How can i Redirect To Action from JsonResult to ActionResult but i m getting error. my error is "Cannot implicitly convert type 'System.Web.Mvc.RedirectToRouteResult' to 'System.Web.Mvc.JsonResult'". My Code Json Result: public JsonResult AddTruckExpensesTransactionChild(string totaldays, string amount) { string Mess = objActive.Save(); if (Mess == "1") { return RedirectToAction("GetTruckExpensesChild", new { id="", sid="" }); } return Json(Mess, JsonRequestBehavior.AllowGet); } ActionResult:

Can i have One form tag inside Another in ASP.net MVC RC2

痞子三分冷 提交于 2019-12-10 15:07:18
问题 I am currently Developing application in MVC2 I have want to used mutiple form tags in My application In My View I have Created a table which has Delete option which i am doing through Post for Individual Delete so i have Create form tag for each button. i also want user to give option to delete mutiple records so i am providing them with checkboxes.This form should have all the values of checkboxes and all. so form gets render Like this for Each delete button <form action="/Home