asp.net-mvc-2

ASP.NET MVC 2 EditModel include Id? Securing Id is not tampered with

女生的网名这么多〃 提交于 2019-12-13 15:04:33
问题 I am looking for some best practices when is comes to creating EditMoels and updating data in an ASP.NET MVC app. Lets say I have a Url like so /Post/Edit?Id=25 I am ensuring the user has permissions to edit the specific post by Id on the Get request and the same for my Post in the controller. I am using the ValidateAntiForgeryToken. Questions: Should I include the Id property in my EditModel? If so, Should I encrypt it? The problem is I can use FireBug to edit the Id hiddedinput and edit a

MVC routing does not work for non-default/root action controller on virtual directory

一笑奈何 提交于 2019-12-13 14:28:31
问题 I am using the default "ASP.NET MVC 2 Web Application" on IIS (which I have no admin access to) and while I can navigate to "server/ITEC" I can't navigate to "server/ITEC/About" without the server returning an error - a 404 error. I'm also using RouteDebugger for testing - when I use the default "server/ITEC" it matches (aka the default home/index controller action) but when I manually type in "server/ITEC/About" I don't even see the RouteDebugger page. Also, of note, when I place an "index

how to get full servername and port running in mvc 2 by codebehind

房东的猫 提交于 2019-12-13 14:24:56
问题 hi every body i have a question example if i have url : http://localhost:8512/bookuser/Create how to get "http://localhost:8512" by code behind in mvc2 ?? thanks regard 回答1: The following will give you the protocol, host and port part of the request Request.Url.GetLeftPart(UriPartial.Authority) 回答2: In MVC3, most directly, You can do it like this (should be pretty same): Within a .cs, You can use code like this: Uri uri = HttpContext.Current.Request.Url; String absoluteUrlBase = String.Format

What's the recommended way to report model state and application errors to client?

可紊 提交于 2019-12-13 12:29:14
问题 I'm wondering what the best practice is in reporting back to the browser about application or model state errors that would be displayed to the user. Can you throw an exception and handle it in the error handler of the jquery post? For example, consider this method: [HandlerErrorWithAjaxFilter, HttpPost] public ActionResult RetrievePassword(string email) { User user = _userRepository.GetByEmail(email); if (user == null) throw new ClientException("The email you entered does not exist in our

Publishing my asp.net mvc application via script and not Visual Studio

别等时光非礼了梦想. 提交于 2019-12-13 12:14:16
问题 I dont really know much about this to be honest with you... I have managed to download mscommunity build and I have managed to use the script below to successfully compile and build my application, however I want to get my asp.net mvc application "published" so I want the same files that you when clicking "publish" inside visual studio. My current build file looks like this: <?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer

ControllerFactory for specific portable area

心不动则不痛 提交于 2019-12-13 11:51:10
问题 My main ASP.NET MVC composite application uses a global Unity container to register types. The app sets the controller factory up to use this global container. I would like to refactor this such that each one of my portable areas leverages it's own child Unity container, so that different areas can implement interfaces in varying ways. It seems like I would need to have a different ControllerFactory per area. How would I accomplish that, given that the following sets the factory for all?

Mvc 5 pagination using view model

北城余情 提交于 2019-12-13 10:01:32
问题 Hi i am newbie to Mvc i have a json service which returns a list of walletstatementlogs based on fromdate and todate. I have a controller TopUpReqLogController every time when i hit the action index of the controller it will go to service and fetch the data and returns to view as Ipagedlist and genrates pagelinks. How do i prevent servicecall everytime in TopUpReqLogController index action i just want to load service data once and pass it to index and display data in pages using int ? page

how do i set the value on a session with jquery?

白昼怎懂夜的黑 提交于 2019-12-13 09:35:50
问题 I need to set the value of a session with jquery. im thinking i need it to be done on server side but how do i do that with jquery? i got a link thats gone trigger the whole thing and my code so far is this. <a href="#" id="showCart">Show Cart</a> $('#showCart').click(function() { $('#cartContainer').show(); //need to the set a session for the site to know if carts gone be visible }); 回答1: For invoking something in the server side, you shall have to invoke a web method or a web page (aspx)

How to reference .html page from .aspx page in the same VS2010 solution?

人盡茶涼 提交于 2019-12-13 08:47:08
问题 This question has to do with the MVC framework and file arrangement conventions within the MVC project folders in VS 2010. It also has to do with filename\path conventions for project files (referencing them from *.aspx and *.html). To assist in answering the question I created a sample project titled "PAPlus.Asp" (a made-up name). Steps to reproduce: open VS2010SP1Rel->File->NewProject->ASP.Net MVC 2 Empty Web Application->Name = "PAPlus.Asp" My question is this: if I create a MVC 2.0

how to get the string from dropdown list

妖精的绣舞 提交于 2019-12-13 07:10:55
问题 I have this code in my controller for Index view.. public ActionResult Index(int? id) { _viewModel.ServiceTypeListAll = new SelectList(_bvRepository.GetAllServiceTypes().ToList().OrderBy(n => n.ServiceTypeName).ToList(), "ServiceTypeId", "ServiceTypeName"); return View(_viewModel); } Using this I am able to dispaly all the ServiceTypes in my view in dropdownlist box. the code is <%=Html.DropDownList("ServiceTypeListAll", new SelectList(Model.ServiceTypeListAll,"Value","Text"))%> When I am