asp.net-mvc-2

Allowing asterisk in URL

给你一囗甜甜゛ 提交于 2019-11-30 21:23:11
I'm having a trouble allowing asterisk (*) in the URL of my website. I am running ASP.NET MVC 2 and .NET 4.0. Here's an example that describes the problem: http://mysite.com/profile/view/Nice * The username is Nice* and ASP.NET says there are illegal characters in the URL: Illegal characters in path. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.ArgumentException: Illegal characters in path. I have tried all the Web

My ASP.NET MVC2 application with Forms Authentication is blocking access even to Images, Styles and Scripts

纵饮孤独 提交于 2019-11-30 21:08:26
I'm developing a MVC2 application and using Forms Authentication on it. The scripts, images and styles are all blocked to unlogged users and, consequently, the login page looks awful. It works well local, the problem is when I publish to the server. Does anyone has any idea WHY???? PS: The server IIS is version 7.5 My Web.config : <configuration> <system.web> <globalization culture="pt-BR" uiCulture="pt-BR" /> <httpRuntime requestValidationMode="2.0"/> <customErrors mode="Off" /> <compilation debug="true" targetFramework="4.0"> <assemblies> <add assembly="System.Web.Abstractions, Version=4.0.0

Is it a bad practice using model classes in controller in mvc?

喜欢而已 提交于 2019-11-30 20:50:56
I wanted to compare with best practices when working with an ORM or database tables in asp.net mvc. One of the major questions I have is should I instantiate the model classes directly in controller..not query the database but just use the model class to store the values. For e.g. If I am using entity framework as model...then is it a bad practice to use the entity class objects in the controller . There are times when it is just easier to directly use the database classes generated in the controller instead of creating ViewModels or even ViewData. We have a data access layer and a Business

Model Binding a Dictionary

十年热恋 提交于 2019-11-30 20:27:21
My controller action method passes a Dictionary<string, double?> to the view. I have the following in my view: <% foreach (var item in Model.Items) { %> <%: Html.Label(item.Key, item.Key)%> <%: Html.TextBox(item.Key, item.Value)%> <% } %> Below is my action method which handles the POST operation: [HttpPost] public virtual ActionResult MyMethod(Dictionary<string, double?> items) { // do stuff........ return View(); } When I enter the some values into the textbox and hit the submit button the POST action method is not getting any items back? What am I doing wrong? I would recommend you reading

How to supress re-post when refreshing a page - ASP.NET MVC

时光怂恿深爱的人放手 提交于 2019-11-30 20:11:49
I am building a wizard using asp.net mvc. currently when the user hits next (or previous) the form values are posted to an action which does any processing required and then renders the next view. the problem i am having is that if the users hit refresh in that new view they get prompted to re-post the form values which causes a ton of problems. In firefox i am getting the message: "To display this page, the application must send information that will repeat any action (such as a search or order confirmation) that was performed earlier." Is there any way to prevent users from being able to re

How to handle `PartialRender` Models?

≯℡__Kan透↙ 提交于 2019-11-30 20:08:33
问题 if by any means I happen to have public class DoorsModel { public DoorsModel() { } public HttpPostedFileBase Image { get; set; } public String DoorLayout { get; set; } public bool ReplicateSettings { get; set; } public List<DoorDesignModel> Doors { get; set; } } public class DoorDesignModel { public DoorDesignModel() { } public HttpPostedFileBase FrontFile { get; set; } public HttpPostedFileBase BorderFile { get; set; } } and in my View I have a normal form to populate the Model Properties

How would you validate a checkbox in ASP.Net MVC 2?

时光毁灭记忆、已成空白 提交于 2019-11-30 19:57:28
Using MVC2, I have a simple ViewModel that contains a bool field that is rendered on the view as a checkbox. I would like to validate that the user checked the box. The [Required] attribute on my ViewModel doesn't seem to do the trick. I believe this is because the unchecked checkbox form field is not actually transmitted back during the POST, and therefore the validation doesn't run on it. Is there a standard way to handle checkbox "required" validation in MVC2? or do I have to write a custom validator for it? I suspect the custom validator won't get executed either for the reason mentioned

JsTree Open a node then select a child node (using json_result)

橙三吉。 提交于 2019-11-30 19:47:23
I am having trouble with a JsTree I am using in an MVC2 project. I would like to create a function to deselect/close all nodes on the tree. Then open a specific node, and select a specific child node (I have the Id values for both). The trouble is that the select_node is always called before the open_node finishes, so the node is not selected, as the tree has not loaded the data yet, and the node ID does not exist. I first tried this function. $('#demo3').jstree('deselect_all'); $('#demo3').jstree('close_all'); $('#demo3').jstree("open_node", $('#ParentId'), false, true); $('#demo3').jstree(

How to deploy SQL CE 4 CTP to shared hosting?

不羁的心 提交于 2019-11-30 19:35:39
How do I deploy SQL CE 4.0 with EF4 to a shared hosting provider for ASP.NET MVC 2.0? I've included System.Data.SqlServerCe.dll, and the amd64 + x86 directories in my bin folder, but keep getting a ".net provider not found". I realize it's currently in CTP, but this is just for testing purposes. My project + host is configured for .net 4.0 Loren Paulsen With Visual Studio 2010 there is now an easy way to deploy SQL CE 4 to a shared hosting environment through the use of "Deployable Dependencies". You do not need to manually copy dlls to your bin folder or modify your web.config. Both of these

TempData implementation changes - Reasons for the change

守給你的承諾、 提交于 2019-11-30 19:16:56
In ASP.NET MVC 2, the lifespan of an entry in the TempDataDictionary was just one HTTP Request. That translated to setting a value in one request, redirecting, and having access to the same item at the other end of the line. After this the entry would be no longer available, regardless of whether you read the value out of the dictionary at the latter end of the line or not. Since ASP.NET MVC 3 (I believe), this implementation detail has changed quite significantly. Entries in the TempDataDictionary are now only removed once they've been read. MVC 4 public object this[string key] { get { object