asp.net-mvc-2

ASP.NET MVC 2 - Html.EditorFor a nullable type?

ε祈祈猫儿з 提交于 2019-12-20 18:43:12
问题 I have two editor templates: one for decimal, and one for decimal? (nullable) But when I have a nullable decimal in my model, it tries to load the normal decimal editor: <%: Html.EditorFor(model => model.SomeDecimal )%> <%: Html.EditorFor(model => model.SomeNullableDecimal )%> The first one works fine, and loads the decimal editor template. The second one also tries to load the decimal template (and fails because it is not a decimal field). The error message is: The model item passed into the

Where are tutorials for DotNetOpenAuth and how to solve compile error in its samples

[亡魂溺海] 提交于 2019-12-20 18:36:20
问题 I know stackoverflow uses OpenID authentication. I want to try and use this as well. I am using asp.net mvc 2.0 with C#. I found this http://www.dotnetopenauth.net/ and I am wondering if this is what was used for stackoverflow. Also any tutorials would be nice as well. Edit I am trying to load up some sample projects but when I build it in VS2010 I get Error 6 'System.Diagnostics.Contracts.ContractInvariantMethodAttribute' is inaccessible due to its protection level C:\Users\chobo2\Downloads

How to Set RadioButtonFor() in ASp.net MVC 2 as Checked by default

二次信任 提交于 2019-12-20 15:45:34
问题 How can i Set RadioButtonFor() as Checked By Default <%=Html.RadioButtonFor(m => m.Gender,"Male")%> there is way out for (Html.RadioButton) but not for (Html.RadioButtonFor) any Ideas? 回答1: This question on StackOverflow deals with RadioButtonListFor and the answer addresses your question too. You can set the selected property in the RadioButtonListViewModel. 回答2: Use the simple way: <%= Html.RadioButtonFor(m => m.Gender, "Male", new { Checked = "checked" })%> 回答3: It's not too pretty, but if

N-Tier Architecture with Service Layer, Business Layer, and Entity Framework

我是研究僧i 提交于 2019-12-20 14:41:33
问题 Just wanted some feedback/help with the way I'm architecturing my application. My current solution structure looks something like this: UI (Actual MVC application) Core (only Controllers & ViewModels) Services BLL Data (Entity framework DbContext, mapped to Domain objects) Domain (Simple POCO objects) Interfaces Other stuff Ninject to inject DbContext into Controller (per request) AutoMapper to map Domain objects to ViewModel All assemblies have a reference to the Interfaces project, which,

ASP.NET MVC 2 editor template for value types, int

别来无恙 提交于 2019-12-20 14:37:33
问题 I want to create a MVC 2 editor template for a value type i.e. int , has anyone done this with the preview 1 bits? Many thanks 回答1: I have not tried preview 1 yet but they did what you are asking for in this channel9 video: http://channel9.msdn.com/posts/Glucose/Hanselminutes-on-9-ASPNET-MVC-2-Preview-1-with-Phil-Haack-and-Virtual-Scott/ They do both DisplayFor and EditorFor, starts around 2 minutes. --Edit-- For value type i.e. int I was able to get it to work in the same way. Create a model

ASP.NET MVC 2 editor template for value types, int

我的梦境 提交于 2019-12-20 14:36:35
问题 I want to create a MVC 2 editor template for a value type i.e. int , has anyone done this with the preview 1 bits? Many thanks 回答1: I have not tried preview 1 yet but they did what you are asking for in this channel9 video: http://channel9.msdn.com/posts/Glucose/Hanselminutes-on-9-ASPNET-MVC-2-Preview-1-with-Phil-Haack-and-Virtual-Scott/ They do both DisplayFor and EditorFor, starts around 2 minutes. --Edit-- For value type i.e. int I was able to get it to work in the same way. Create a model

ASP.NET MVC3 Partial View naming convention

♀尐吖头ヾ 提交于 2019-12-20 10:59:16
问题 I'm new to the MVC development so please bear with me. Is it really necessary to name my partial view like _Action.cshtml (with the _ underscore) to comply with the naming convention? Here's my problem I have a controller (StudentController) and an action (List) that has a partial view file named "List.cshtml", and have @{ Html.RenderAction("List", "Student"); } to display this inside my HomeController - Index view as partial view which works. But if I name my partial view to _List.cshtml of

ASP.NET MVC3 Partial View naming convention

走远了吗. 提交于 2019-12-20 10:59:05
问题 I'm new to the MVC development so please bear with me. Is it really necessary to name my partial view like _Action.cshtml (with the _ underscore) to comply with the naming convention? Here's my problem I have a controller (StudentController) and an action (List) that has a partial view file named "List.cshtml", and have @{ Html.RenderAction("List", "Student"); } to display this inside my HomeController - Index view as partial view which works. But if I name my partial view to _List.cshtml of

Where to put Entity Framework Data Model in MVC application?

♀尐吖头ヾ 提交于 2019-12-20 10:33:52
问题 Lets consider default ASP.NET MVC application folder structure, so it's looks like this: -App_data -Content -Controllers HomeController.cs -Models AccountModels.cs -Scripts -Views My question is: Where is the best place to put Entity Framework Data Model (EDMX) file? Is it Models folder? Yes - we know that good solution is to introduce new Project and reference it to MVC application, but lets forget about this now. 回答1: For a small project, it should be part of the Model. For a larger product

ASP.NET MVC Authorize Attribute does a 302 redirect when the user is not authorized

做~自己de王妃 提交于 2019-12-20 10:33:40
问题 MSDN explicitly says it should do 401 redirect, but I'm getting a 302 redirect on FF, and this is causing problems in AJAX requests as the returned status is 200 (from the redirected page). http://msdn.microsoft.com/en-us/library/system.web.mvc.authorizeattribute.aspx I've found someone else with the same problem: http://blog.nvise.com/?p=26 Any other solution, besides his? 回答1: The Authorize attribute does return a Http 401 Unauthorized response. Unfortunately, however if you have