asp.net-mvc-2

Can't get jquery $ajax to call .NET MVC 2 controller method

雨燕双飞 提交于 2019-12-11 10:48:51
问题 I'm new to jquery and ajax - just can't seem to get this to work! See my related question: Use Json and AjaxLink to Toggle Link Values in ASP.NET MVC 2 Here's my jquery: $(function () { $("div[id^=add]").click(function (ev) { ev.preventDefault(); updateMe(this.id.split('_')[1], "AddRequirement"); }); $("div[id^=remove]").click(function (ev) { ev.preventDefault(); updateMe(this.id.split('_')[1], "RemoveRequirement"); }); }); function updateMe(myId, myAction) { $.ajax({ type: "POST", url:

Disable IIS logging on individual MVC controller

↘锁芯ラ 提交于 2019-12-11 10:46:23
问题 I have a few particular actions in a controller and I do not want IIS (6) to log the requests, but only on that particular controller. I want it to log as normally for the rest of my site. Is this even possible? 回答1: You will need to write a custom logging module for this. By default it's all or nothing. 来源: https://stackoverflow.com/questions/4752513/disable-iis-logging-on-individual-mvc-controller

adding URL to html.grid column

牧云@^-^@ 提交于 2019-12-11 09:59:36
问题 !{Html.Grid(Model.Results) .Columns(column => { column.For(x => x.Title).Named("Article Name"); column.For(x => x.Sites); column.For(x => x.PreviousPath).Named("Previous Path"); column.For(x => x.CurrentPath).Named("Current Path"); column.For(x => x.PreviousUrl).Named("Previous Url"); column.For(x => x.CurrentUrl).Named("Current Url"); column.For(x => x.LogDate).Named("Date"); } ) .Empty("There are no R301s.") } In the above grid I have a CurrentUrl. This URL is pointing to a website. I need

Can we dynamically change the URL with Ajaxy call on ASP.NET MVC page?

送分小仙女□ 提交于 2019-12-11 09:47:24
问题 I have an ASP.NET MVC application that has a view called Products. This Products View has a Left Menu Navigation that is implemented using NavMenuProducts.ascx Partial View. This Menu is implemented using JQuery Treeview so that it has the list of ProductNames as the Parent Node and it is expandable(For Example: 10 Products). Each of these Products have a ChildNode as DocTypeName and it is a hyperlink(For Example: 3 DocTypeNames). When the user clicks ChildNode Hyperlink all the matching

Custom Validator: IsValid is not called when using overloaded method

北慕城南 提交于 2019-12-11 08:49:39
问题 If I do the following: public class CustomRangeAttribute : RangeAttribute { public override bool IsValid(object value) { return base.IsValid(value); } } The method is executed as expected. If I do: protected override ValidationResult IsValid(object value, ValidationContext validationContext) { return base.IsValid(value, validationContext); } The method is not called. Why? sl3dg3 回答1: This works exactly as you'd expect if you are using ASP.NET MVC 3.0 . I tried it myself using your example and

Html.Hidden builds wrong value data in MVC 2 app

狂风中的少年 提交于 2019-12-11 08:45:43
问题 I am using an id value that I pass in a hidden field. When the user submits the form I need the hidden field for my update. After the update, a new value is placed in the hidden field in the model and sent back to the view. What seems so strange is the helper always uses the first value, never updates. For example, look at the following from the View: <%: Html.Hidden("MyId",Model.MyId) %> <%: Model.MyId %> First time in a look at the source in the browser yields: <input type="hidden" id="MyId

Different behavior in GET vs. POST Ajax request

删除回忆录丶 提交于 2019-12-11 08:45:41
问题 We have an MVC app that uses controllers for AJAX endpoints, and FormsAuth for authentication. I've run into an interesting scenario where a GET request will behave differently than a POST request (both for an unauthorized user). In this particular case, our custom ControllerFactory runs the following code trying to access this controller: FormsAuthentication.SignOut(); requestContext.HttpContext.Response.Redirect(FormsAuthentication.LoginUrl); throw new UnauthorizedAccessException(); (I

The directory or file specified does not exist on the Web server

心不动则不痛 提交于 2019-12-11 08:09:19
问题 I have a hybrid asp.net web forms / mvc application that I recently converted to .net 4 with mvc2. I have set-up that application to run on IIS 7.5 (on Windows 7) and the web forms part of the site is running okay but the MVC part is not. Whenever I try and access a page that needs to go through the routing engine I get HTTP Error 404.0 - Not Found The resource you are looking for has been removed, had its name changed, or is temporarily unavailable. Module IIS Web Core Notification

Showing an image blob in MVC2

柔情痞子 提交于 2019-12-11 08:09:01
问题 I'm trying (without success) to fetch a blob image from a service and show it as an image in html. my html is: <img src="<%: Url.Action("GetPersonImage", new { pid = Model.PersonId }) %>" alt="" /> witch shows in the Source as <img src="/demo4/ABook/GetPersonImage/?pid=210092" alt=""> my action is: public void GetPersonImage(int pid) { string src = so.GetPersonImage(pid); byte[] bytes = System.Text.Encoding.UTF8.GetBytes(src); Response.Clear(); Response.AddHeader("Content-Length", src.Length

ASP.NET MVC2: Can't find controller

心不动则不痛 提交于 2019-12-11 07:35:09
问题 I have an MVC 2.0 web site that is using Areas. When I go to the default page (localhost/mywebsite/default.aspx), it correctly routes to the correct action in the correct controller and renders the default view correctly. But on the page I have several Html.ActionLinks, and these do not seem to be able to find the Controller. When I click on the links in the page, I get a 404 error. The URLs are what I expect: localhost/mywebsite/MyAreaName/Home/Index (for example). I've also tried localhost