asp.net-mvc

How to get controller type by its name

I have a list of controller names and their actions names. What I need to do is to read values from custom attributes on those actions. The problem is that it seems there is no easy way to get controller types (Having that the rest is easy.) ASP.NET MVC framework has this functionality in DefaultControllerFactory, but it's not accessible...

How do I get the "Add Controller" and "Add View" menu options in my ASP.NET MVC project?

I added ASP.NET MVC manually to an existing WebForms application... thanks to this tutorial. However, now I do not have the menu options (When right-clicking on the Controllers folder or Views folders) to show the Add Controller or Add View dialog boxes. I do have this when creating a brand new MVC project. How can I get visual studi...

How do I log unhandled exceptions in ASP.NET MVC?

Here's what I'm trying to do in my Global.asax.vb: Public Class MvcApplication Inherits System.Web.HttpApplication Shared Sub RegisterRoutes(ByVal routes As RouteCollection) routes.IgnoreRoute("{resource}.axd/{*pathInfo}") routes.MapRoute( _ "Error", _ "error.html", _ New With...

ASP.NET MVC: How to view query executed by SaveChanges (on the ADO.NET Entity Data Model)

When trying to add a few items to the database I'm getting this error: UpdateException was unhandled by user code An error occurred while updating the entries. See the InnerException for details. The InnerException contains this: {"Column count doesn't match value count at row 1"} I can't see anything wrong with the objects...

When dealing with a single page, ViewState is a better choice than QueryString for maintaining state. Why?

I am reading the article: Nine Options for Managing Persistent User State in Your ASP.NET Application by Steven A. Smith (Doesn't he host a show on ESPN?) In the article, Steven makes the following statement: "When dealing with a single ASP.NET page, ViewState is a better choice than QueryString for maintaining state" Unfortunately, h...

Error Handling in ASP.NET MVC

How can I correctly handle exceptions thrown from controllers in ASP.NET MVC? The HandleError attribute seems to only process exceptions thrown by the MVC infrastructure and not exceptions thrown by my own code. Using this web.config <customErrors mode="On"> <error statusCode="401" redirect="/Errors/Http401" /> </customErrors> ...

Embed ContentPlaceHolder between double quotes

I am using .NET MVC, and within view pages I set a contentplaceholder that contains an ID to be used on the master page like so: View page: <asp:Content ID="CDomBodyId" ContentPlaceHolderID="DomBodyId" runat="server">LmpDemoRequests</asp:Content> Master page: <body id='<asp:ContentPlaceHolder ID="DomBodyId" runat="server"></asp:Cont...

How to specify the location a Mvc view will be created for a Mvc controller?

Important Update Since the release of MVC 2.0 Preview 1 this feature has been implemented as the part of the actual framework itself in the form of Areas. More details available on Phil Haack's blog here I have a controller called ListManagerController. This controller contain an ActionResult method called Index(). When I right ci...

PartialView renders new page instead of in div

Hi, I had this problem before and can't for life of me remember how to fix it or where I googled about it. I am passing back from an action a partial view return PartialView("CommentsListControl", recipe.Comments); But this loads a new web page and not into my div WHY????????? <table width="100%"> <tr><td> <div...

Good ASP.NET books for the beach

or train, plane or couch. Most programming books are quite thick and require you to sit at a computer while you read it. Some of the thinner ones, like "Efficient C++" for example, are much better written and you can read them on the couch. I am looking for books like that on recent ASP.NET technologies. One example (though not reall...

Asp.net MVC form validation Related

I don't know whether people have already asked this question or they haven't seen this problem or whatever. I am Creating Strongly type view for each Create view. I am validating the form at server side by making partial class of LINQ class Entities. By adding Function Like public IEnumerable<RuleViolation> GetRuleViolations() {...

Error when accessing anything but default route

I am having trouble getting routing to work on mono. The default route works fine but nothing else does. These are the routes I have setup: routes.MapRoute( "HelloRoute", "Hello/{name}", new { controller = "Home", action = "Hello" } ); routes.MapRoute( "Default", ...

How do I redirect to the previous action in ASP.NET MVC?

Lets suppose that I have some pages some.web/articles/details/5 some.web/users/info/bob some.web/foo/bar/7 that can call a common utility controller like locale/change/es or authorization/login How do I get these methods (change, login) to redirect to the previous actions (details, info, bar) while passing the previous parameters...

Ways to workaround whole page caching in ASP.NET MVC

Currently ASP.NET MVC's OutputCache attribute has a huge downfall. If you want to cache parts of your site you have to use a workaround due to the limitation of ASP.NET's pipeline that MVC relies on. Say you have a page that has a statistics module that you surface through RenderAction you can't cache just that part of the page out of ...

In ASP.NET MVC, how to define in which sequence my custom attributes are checked/applied?

I'm currently investigating the possibility to use custom attributes derived from ActionFilterAttribute. I want to accomplish a couple of things with a couple of attributes. The thing is I want to make sure one of the attributes comes into play first, and not in any random sequence. Example: public class Feature1Attrubute : ActionFilte...

How to turn route into URL in ASP.NET MVC Controller?

In a View, code like this will generate the right URL to jump to controller's action method based on the routes in your global.asax.cs file. <%= Html.ActionLink("text", "action", "controller") %> My question is how can I achieve a similar route-to-URL mapping outside a view, such as a Controller? There is no Html member on the Cont...

OpenID Login Helper Buttons

Is there an easy way to implement OpenID login "helper buttons" similar to the buttons on the stackoverflow and uservoice login pages if you're already using a library like DotNetOpenId? It looks like RPX solves half of the problem, but it would require re-implementing the login code to use their methods. ...

Which to use: "AcceptGet, AcceptPost"(MvcContrib) vs. AcceptVerbs(ASP.NET Mvc)?

In ASP.NET MVC controller methods can be decorated to accept on specific HTTP Methods(Get, Post, Get.. etc). Between MvcContrib and ASP.NET MVC there are 3 classes: "AcceptGet, AcceptPost" and AcceptVerbs. All three: "AcceptGet, AcceptPost" and AcceptVerbs do the same thing. They specify what http method is allowed to access a action/met...

How to enable membership provider for sql server express database.

Hi, I am playing with ASP.NET MVC with visual webdeveloper express edtion 2008 and sql server express edition. I am creating a site that will use membership provider for that i want to use my own databse not the application services database. I have created my database in app_data folder but still I am not able to register it using aspn...

ASP.net MVC - how does the view access the model?

In all MVC Diagrams i've seen, there is always a connection between the View and the Model, indicating that the View has access to the Model. I just wonder: When does this apply? At the moment, I have my Controller Action taking in a Parameter from the QueryString, query the Model in order to get MyObjectViewData, and then return a View...