asp.net-mvc-2

Database connection string and collation

六眼飞鱼酱① 提交于 2019-12-01 08:53:27
问题 Is it possible to set connection collation within MySql connection string and how, since there's a default setting on the server that's used for new connections. Two things I can't do : Can't call SET COLLATION_CONNECTION after I open a connection, because I'm using Entity Framework that does all the calls for me not entirely true as you may see in the edit Can't change server default connection collation because of other databases and their respected applications that use them. All I'd like

Shouldn't MVC ignore images by default?

ε祈祈猫儿з 提交于 2019-12-01 08:48:49
If there is 1.jpg image, so it is downloaded and showed <img src="Content/Pages/1.jpg" /> But, if there is no 1.jpg image in Pages folder, so I get the following error The controller for path '/Content/Pages/1.jpg' could not be found or it does not implement IController. I fixed it by registering route to IgnoreRoute , but shouldn't it ignore images by default? routes.IgnoreRoute("Content/{*pathInfo}"); That's actually handled by your hosting environment/web server, not by MVC per-se. I suspect you are using the Visual Studio Web Server during development, right? The Visual Studio Web Server

CS0012: The type 'System.Web.Routing.RouteValueDictionary' is defined in an assembly that is not referenced

﹥>﹥吖頭↗ 提交于 2019-12-01 08:30:29
I got this error using a new "ASP.NET MVC 2 Empty Web Application" project: CS0012: The type 'System.Web.Routing.RouteValueDictionary' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Update web.config file: <?xml version="1.0"?> <configuration> <system.web> <compilation debug="true" targetFramework="4.0"> <assemblies> <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> <add assembly="System.Web.Routing, Version

Error handling for ASP.NET MVC 2 and IIS 7.0

廉价感情. 提交于 2019-12-01 08:29:00
Good day! I've recently switched from IIS 6.0 to IIS 7.x and I'm in search of error handling technique of my dream for ASP.NET MVC 2. What I want to achive: Handle all unhandled exceptions in one place (preferable in Global.asax handler) Custom handlers for 404 and 403 errors (both for MVC controller\actions and static files). These handlers should not perform rewriting and should send HTTP error codes. For example if user navigates to http://example.com/non-existing-page/ he should remain on this URL, but get HTTP 404 status and custom 404 page. Ability to trigger 404 and 403 errors

ASP.NET MVC 2 RC2 Routing - How to clear low-level values when using ActionLink to refer to a higher level?

陌路散爱 提交于 2019-12-01 08:02:18
问题 [NOTE: I'm using ASP.NET MVC2 RC2.] I have URLs like this: /customers/123/orders/456/items/index /customers/123/orders/456/items/789/edit My routing table lists the most-specific routes first, so I've got: // customers/123/orders/456/items/789/edit routes.MapRoute( "item", // Route name "customers/{customerId}/orders/{orderId}/items/{itemId}/{action}", // URL with parameters new { controller = "Items", action = "Details" }, // Parameter defaults new { customerId = @"\d+", orderId = @"\d+",

Distinguishing controller actions using authorization filters

拜拜、爱过 提交于 2019-12-01 07:41:21
问题 I would like to have 4 actions with the same name (controller methods may have a different name, but their ActionName() attribute is the same for all 4 of them: [ActionName("Same-name")] public ActionResult AnonAction() { ... } [HttpPost] [ActionName("Same-name")] public ActionResult AnonAction(ModelData data) { ... } [Authorize] [ActionName("Same-name")] public ActionResult AuthAction() { ... } [HttpPost] [Authorize] [ActionName("Same-name")] public ActionResult AuthAction(OtherData data) {

CS0012: The type 'System.Web.Routing.RouteValueDictionary' is defined in an assembly that is not referenced

人走茶凉 提交于 2019-12-01 07:14:04
问题 I got this error using a new "ASP.NET MVC 2 Empty Web Application" project: CS0012: The type 'System.Web.Routing.RouteValueDictionary' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. 回答1: Update web.config file: <?xml version="1.0"?> <configuration> <system.web> <compilation debug="true" targetFramework="4.0"> <assemblies> <add assembly="System.Web.Abstractions,

Implementing a custom SessionIDManager

╄→尐↘猪︶ㄣ 提交于 2019-12-01 07:07:51
问题 I'm trying to implement a custom SessionIDManager very similar this example. I'm putting this in the web.config similar to how they showed in the example: <system.web> <httpModules> <add name="SessionID" type="ProjectName.WebUI.Models.CustomSessionIDManager" /> </httpModules> // --snip-- </system.web> However when attempting to load the website I am getting the configuration error: ProjectName.WebUI.Models.CustomSessionIDManager does not implement IHttpModule. If I remove that part of the web

Ordering Entity Framework sub-items for EditorFor

半城伤御伤魂 提交于 2019-12-01 06:47:40
问题 I've seen Ordering sub-items within ordered items in a Linq to Entities Query which suggests that there is no way of getting the repository to return sub-items in an entity graph in a specific order. If that's right, any thoughts on how to order the items in an EditorFor ? i.e. //This works but returns a random order <%: Html.EditorFor(model => model.HPERDET.HORDERS) %> //This errors with "Templates can be used only with field access, property access, single-dimension array index, or single

Global action filter in ASP.NET MVC

雨燕双飞 提交于 2019-12-01 05:21:38
Is it possible to create a global action filter that will automatically apply to all actions in all controllers in ASP.NET MVC application? I want something like "before_filter" defined in ApplicationController in Ruby on Rails. Thank you for your help. This really depends what you want to do with it. In many scenarios, the previous answers by vucetica and Adeel will be what you actually want to do. However, neither of them meet the criteria you listed: automatically apply to all actions/controllers . To do something like that, you would need to implement a handler for the Application