asp.net-mvc-2

MVC 2 with VS 2010 View Building Error: Feature 'anonymous types' cannot be used because it is not part of the ISO-2 C# language specification

做~自己de王妃 提交于 2019-12-05 02:45:09
问题 I have a shared project where I store all of my custom EditTemplates and DisplayTemplates. This is a regular C# class library project with the views all tagged as embedded resources. The target framework of this project is ".Net Framework 4". Inside the /Views/ folder I have included this web.config file so I get MVC 2 intellisense when working with the .aspx and .ascx files: <?xml version="1.0"?> <configuration> <system.web> <httpHandlers> <add path="*" verb="*" type="System.Web

IntegrationTests - A potentially dangerous Request.Path value was detected from the client

谁都会走 提交于 2019-12-05 02:18:04
问题 I get this error: A potentially dangerous Request.Path value was detected from the client (?). when this URI: http://www.site.com/%3f . How can I write an integration tests around of all of this type of errors? I want to test against all this erros: A potentially dangerous Request.Path value was detected from the client A potentially dangerous Request.Cookies value was detected from the client A potentially dangerous Request.Form value was detected from the client A potentially dangerous

ASP.NET MVC + MySql Membership Provider, user cannot login

对着背影说爱祢 提交于 2019-12-05 01:04:25
问题 I've been playing around with using MySql as the membership provider for asp.net mvc forms authentication. I've got things configured correctly as far as i can tell, and i can create users via both the register action and asp.net web config site. however, when i try to login with one of the users, it does not work. it returns an error as if i had entered a wrong password, or if the account doesn't exist. i have verified in the database that the account does exist. I've followed the

advice on architecting asp.net mvc applications

泪湿孤枕 提交于 2019-12-05 00:38:39
问题 I've been using ASP.net MVC for about two years now and I'm still learning the best way to structure an application. I wanted to throw out these ideas that I've gathered and see if they are "acceptable" ways in the community to design MVC applications. Here is my basic layout: DataAccess Project - Contains all repository classes, LINQ-to-SQL data contexts, Filters, and custom business objects for non-MS SQL db repositories (that LINQ-to-SQL doesn't create). The repositories typically only

Entity Framework CTP4: where to put SetInitializer?

杀马特。学长 韩版系。学妹 提交于 2019-12-05 00:11:54
问题 I am attempting to add Entity Framework, code first, to an MVC application that's been running with test data, using the CTP4 preview. I am currently getting this error: The model backing the 'SchedulerContext' context has changed since the database was created. Either manually delete/update the database, or call Database.SetInitializer with an IDatabaseInitializer instance. For example, the RecreateDatabaseIfModelChanges strategy will automatically delete and recreate the database, and

Mocking HttpRequest and HttpResponse for MVC Application

混江龙づ霸主 提交于 2019-12-04 23:56:00
I'm currently writing some unit tests to check the functionality and correct workings of the ASP MVC application that we have written. In this MVC Application, I'm using a special ActionFilterAttribute that allows for authentication when making requests to the MVC Application. The code for this ActionFilterAttribute is this: using System; using System.Security.Authentication; using System.Text; using System.Web.Mvc; using TenForce.Execution.Framework; using TenForce.Execution.Api2.Implementation; namespace TenForce.Execution.Web.Filters { /// <summary> /// This class defines a custom

Custom IIdentity and IPrincipal using FormsAuthenticationTicket cookie in MVC2

倖福魔咒の 提交于 2019-12-04 23:46:30
问题 I am currently trying to implement some custom security in an ASP.NET MVC2 web application. I am trying to do something really simple as my code below shows but for some reason if I use the [Authorize(Roles="Admins")] attribute on one of my controller actions, check the Context.User.IsInRole("Admins") or Page.User.IsInRole("Admins") it is always false. It is also weird that the User.Identity.Name is also blank. See my code below, I am using a FormsAuthenticationTicket within a cookie which I

Can you pass a model with RedirectToAction?

二次信任 提交于 2019-12-04 23:13:16
I'm using mvc 2 release candidate, and am wondering if there's any way to pass a model to an action using RedirectToAction. For example, I have an edit action which takes an ID, and loads the record from a database, displays the current values in text boxes and lets the user edit and click submit: public ActionResult Edit(int ID) Then I have an edit action for the HttpPost which takes a model and updates the database: [HttpPost] public ActionResult Edit(Administration.Models.ManagementCompanyModel model) Because I already have the model containing the new data, I don't want to simply re-direct

Undoing “Set as Start Page”

元气小坏坏 提交于 2019-12-04 22:52:53
I set one of my ASP.net pages to the default start page in Visual Studio. This results in a 404 error when I try to debug my project. How do I clear this? Thanks, Barry Right click the MVC project and select properties. Go to the Web tab. Under Start Action, select either Current Page or Don't open a page. 来源: https://stackoverflow.com/questions/8464070/undoing-set-as-start-page

Can ASP.NET MVC html helpers render an element without an ID attribute?

情到浓时终转凉″ 提交于 2019-12-04 22:42:09
Assume I want to generate an element similar to this in ASP.NET MVC 2: <%= Html.TextBoxFor(p => p.FooBar)%> Is there an overload or way I can get ASP.NET MVC 2 to only generate a name attribute and not an ID attribute? I can have it generate a blank id with <%= Html.TextBoxFor(p => p.FooBar, new { id = "" })%> , but I would like to generate the element with no ID at all, and without overriding the asp.net mvc framework. The behavior of the HTML helpers was changed as of MVC 2 RC1 so that passing new { id = "" } suppresses id entirely rather than outputting an empty id attribute. 来源: https:/