asp.net-mvc-2

Asp.net MVC Authentication how does the Authentication work

无人久伴 提交于 2019-12-11 03:32:19
问题 May be my question is crazy. 1) ASP.net MVC is stateless, so there is no session involved in here. How does the authentication module work and do you have any articles which you can point me to understand the Authentication basics. What are the authentication information stored in. [Novice MVC] 回答1: The web is stateless. Both ASP.NET and ASP.NET MVC have mechanisms for creating an application state. Advocates of MVC like that it provides the developer with more control over how state is

ASP.NET MVC 2 - Handling files in an edit action; Or, is it possible to create an 'Optional' data annotation which would skip over other attributes?

主宰稳场 提交于 2019-12-11 03:22:20
问题 I've run into a bit of a design issue, and I'm curious if anyone else has run into something similar. I have a fairly complex model which I have an Edit action method for. Each individual entity has two images associated with it, along with other, more mundane data. These images are [Required] upon creation. When editing an entity, however, these images already exist, since, again, they were required upon creation. Thus, I don't need to mark them as required. Adding a bit of a monkey wrench

ASP.NET MVC 2 - Problem with Request encoding

删除回忆录丶 提交于 2019-12-11 03:14:17
问题 Hello! There is a controller and an action which receives one param through GET, approximately here so: www.site.com/controller/action/?query=параметр <- Russian word Problem: Example 1: www.site.com/controller/action/?query=Пример <- Russian word Example 2: www.site.com/controller/action/?query=Example Reading param: var param = Request.QueryString["query"]; Result 1: param = "������" The data from debugger: Request.RawUrl = "/controller/action/?q=%CF%F0%E8%EC%E5%F0" QueryString = {q=%ufffd

Model binding postback data to a controller action parameter of type List<T>

荒凉一梦 提交于 2019-12-11 03:09:58
问题 I have a strong type view of type List<List<MyViewModelClass>> The outer list will always have two lists of List<MyViewModelClass> . For each of the two outer lists I want to display a group of checkboxes. Each set can have an arbitrary number of choices. My view model class looks similar to this: public class MyViewModelClass { public Area Area { get; set; } public bool IsGeneric { get; set; } public string Code { get; set; } public bool IsChecked { get; set; } } So the final view will look

Where to put data annotations tags?

百般思念 提交于 2019-12-11 03:04:24
问题 I am going through pro asp.net mvc 2.0 framework and it seems that he puts his data annotation tags on classes that also generate the linq to sql. [Table(Name = "Products")] public class Product { [HiddenInput(DisplayValue = false)] [Column(IsPrimaryKey = true, IsDbGenerated = true, AutoSync = AutoSync.OnInsert)] public int ProductID { get; set; } [Required(ErrorMessage = "Please enter a product name")] [Column] public string Name { get; set; } [Required(ErrorMessage = "Please enter a

RedirectToAction not working when called by jQuery?

空扰寡人 提交于 2019-12-11 02:54:33
问题 I am trying to call an action method by jQuery, and got help with passing parameters here: Calling action method in MVC with jQuery and parameters not working . However, even though the parameters are sent correctly now, in the action method I need to redirect (passing on those same parameters) to another action method. In the debugger I can see that the redirect is carried out, and the parameters are still there, but the View returned doesn't update accordingly... Is there some problem with

How can I serialize entities from an ASP.NET MVC site to XML?

大城市里の小女人 提交于 2019-12-11 02:38:18
问题 I am working on an ASP.NET MVC (in c#) site which connects to a database and takes advantage of the entities framework. I'd like people to be able to modify the information in the database from the site (since it seems to me to be much easier to display and validate data via an ASP.NET MVC site than a Desktop app while being much easier to distribute the tools to do). Then I want users to be able to export the database (after the changes they made) to an XML file which can be loaded by a

Passing HTML Attributes and [DisplayFormat] using Html.EditorFor and Html.TextBox

杀马特。学长 韩版系。学妹 提交于 2019-12-11 02:28:38
问题 I am trying to use Html.EditorFor for a value where I need both a DisplayFormat attribute and an HTML attribute (specfically a CSS class) to be applied. Html.TextBox ignores the DisplayFormat attribute, and Html.EditorFor will not let me pass Html attributes. Other than writing the HTML myself, what is the preferred solution here? 回答1: Here's one possibility: public class MyModel { [UIHint("MyDateTemplate")] public DateTime Value { get; set; } } and in ~/Views/Home/EditorTemplates

TypeConverter prevents ApplyPropertyChanges in EntityFramework

霸气de小男生 提交于 2019-12-11 02:27:48
问题 I ran into an interesting problem (hopefully, interesting not just for me :) I am running Entity Framework 1 (.NET 3.5) and ASP.NET MVC 2. I have a Customer class that has many-to-one relationship with Country class (in other words, Country is a lookup table for customers - I described more in this post: Explicit casting doesn't work in default model binding ) I got TypeConverter to work; so I am getting a perfect object into controller's Post method. Create works fine; however, in Edit I am

Is there a way to allow a user to submit html content while still enabling model validation?

蹲街弑〆低调 提交于 2019-12-11 02:13:40
问题 I need to allow users to submit a form value containing html in their text inputs. This is an internally-facing application so it's reasonably safe to do so. I have succesfully used the [ValidateInput(false)] attribute on the method in question, but this inhibits all model validation for the method/view model in question, but I only want to allow html in one of the TextBoxes and do not necessarily wish to write my own guard clauses for every other piece of model validation in the same method