asp.net-mvc-2

How to correctly canonicalize a URL in an ASP.NET MVC application?

让人想犯罪 __ 提交于 2019-12-20 10:01:36
问题 I'm trying to find a good general purpose way to canonicalize urls in an ASP.NET MVC 2 application. Here's what I've come up with so far: // Using an authorization filter because it is executed earlier than other filters public class CanonicalizeAttribute : AuthorizeAttribute { public bool ForceLowerCase { get;set; } public CanonicalizeAttribute() : base() { ForceLowerCase = true; } public override void OnAuthorization(AuthorizationContext filterContext) { RouteValueDictionary values =

Cannot get assembly version for footer

拈花ヽ惹草 提交于 2019-12-20 09:48:21
问题 I'm using the automatic build versioning mentioned in this question (not the selected answer but the answer that uses the [assembly: AssemblyVersion("1.0.*")] technique). I'm doing this in the footer of my Site.Master file in MVC 2. My code for doing this is as follows: <div id="footer"> <a href="emailto:webmaster@foo.com">webmaster@foo.com</a> - Copyright © 2005-<%= DateTime.Today.Year.ToString() %>, foo LLC. All Rights Reserved. - Version: <%= Assembly.GetEntryAssembly().GetName().Version

Using NServiceBus with Asp.Net MVC 2

戏子无情 提交于 2019-12-20 09:24:25
问题 Is there a way to using NServiceBus with Asp.Net MVC 2? I want to send a request message from a Asp.Net MVC2 Application to a Service, which handle the message and reply with a response message. is there a way to do this clearly? 回答1: If you really want to do this, here's how: var sync = Bus.Send<SomeMessage>(/*data*/) .Register((AsyncCallback)delegate(IAsyncResult ar) { var result = ar.AsyncState as CompletionResult; // do something with result.Messages }, null ); sync.AsyncWaitHandle

Where is the best place to map from view model to domain model?

荒凉一梦 提交于 2019-12-20 09:04:03
问题 Where is the best place to do mappings from view model to domain model? By mappings I mean from my EditGrantApplicationViewModel to a GrantApplication object. Lets say that I have the following action method (partial code): [HttpPost] public ActionResult Create(EditGrantApplicationViewModel editGrantApplicationViewModel) { if (!ModelState.IsValid) { return View("Create", editGrantApplicationViewModel); } return View("Index"); } Do I need to pass editGrantApplicationViewModel to a service

MVC2 EditorTemplate for DropDownList

我怕爱的太早我们不能终老 提交于 2019-12-20 08:15:11
问题 I've spent the majority of the past week knee deep in the new templating functionality baked into MVC2. I had a hard time trying to get a DropDownList template working. The biggest problem I've been working to solve is how to get the source data for the drop down list to the template. I saw a lot of examples where you can put the source data in the ViewData dictionary (ViewData["DropDownSourceValuesKey"]) then retrieve them in the template itself (var sourceValues = ViewData[

ASP.net MVC Controller - Constructor usage

女生的网名这么多〃 提交于 2019-12-20 08:02:56
问题 I'm working on an ASP.net MVC application and I have a question about using constructors for my controllers. I'm using Entity Framework and linq to Entities for all of my data transactions. I need to access my Entity model for nearly all of my controller actions. When I first started writing the app I was creating an entity object at the beginning of each Action method, performing whatever work I needed to and then returning my result. I realized that I was creating the same object over and

Need to update the check box value to db table when i click the checkbox() without post back in MVC2

风流意气都作罢 提交于 2019-12-20 07:18:42
问题 <input type="checkbox" name="n" value=1 /> <input type="checkbox" name="n" value=2 /> <input type="checkbox" name="n" value=3 /> I have above checkbox when i select the this i need to update the DB table without post back. Please explain.. If possible you can say jquery or ajax method to solve my problem 回答1: You have to do some sort of request back to the server, whether it's a POST from a form button or an Ajax POST or GET request. Form button: <form action="/MyApp/HandleClick/" method=

ASP.NET MVC 2 Reload pages without refresh and keep URL changing

放肆的年华 提交于 2019-12-20 07:17:12
问题 I am creating a project using ASP.NET MVC. I want to show content of pages in the placeholder without refreshing the page, something like ajax but WITH the URL changing, How can I accomplish this ? Thank you for your responses 回答1: I've used the jQuery BBQ plugin (http://benalman.com/projects/jquery-bbq-plugin/) with great success. This and the jQuery Templating engine would be great for what you are trying to accomplish. 回答2: If you change the url of the browser this will automatically

Putting icon instead of “ + ” or “ - ” in an accordian menu.js file

怎甘沉沦 提交于 2019-12-20 06:05:15
问题 I am making an accordian menu. I just found this link http://jsfiddle.net/zM5Vj/ , and it is almost similar to the accordian menu I have made. In the code, where there is if($(this).text() == "-") { $(this).text("+"); } else { $('#accordion .opener').text("+"); $(this).text("-"); } }); If insted of "+" and "-", i want to put icons "~/Image/iconplus.gif" and "~/Image/iconminus.gif". How do i do so? I have tried <img src="..."/> But still it is of no use. Please can anyone help? Thanks in

ASP.NET MVC2: “System.MissingMethodException: No parameterless constructor defined for this object.”

删除回忆录丶 提交于 2019-12-20 04:22:44
问题 I am currently trying to modify the registration component of the default MVC project to accommodate a bit more to my project. I have modified the RegisterModel, Register.aspx and AccountController to do so. I can view the register view just fine, but when I submit, i get the error in the title, and it gives me little to nothing in the way of where the problem stems from. Can someone please steer me in the correct direction for me to fix this? UPDATE: I have added the inner exception as well