asp.net-mvc

Why do I get a TypeInitializationException when calling HtmlHelper.AntiForgeryToken?

Preamble I've searched to see if I can find this question anywhere on here and I can't. I previously asked on meta if it would be valid to report the bug on SO. The consensus was that I should report the bug at the source and if I was feeling community minded, perhaps to ask and answer the question on SO so that other people might com...

How to make Interface available in all Controllers?

I have a number of Controllers, and I want them all to have an interface to a PageConfiguration object that needs to be created based on the URL. I'm not sure how to do this other than to create the interface in the action methods, because they have access to Request.QueryString, where the Controllers constructors don't. Do I need to cre...

log4net with MySql db

hi i am storing information of log using log4net.i have referred following link for this. http://blogs.lessthandot.com/index.php/WebDev/ServerProgramming/using-postsharp-and-log4net-to-set-up-co but now i am facing performance issue.My application taking lots of time for logged in due to storing information in mysql db. Please lemme ...

How do I enable users to send email from ASP.NET MVC?

I'm developing a web application in ASP.NET MVC, and I want users to be able to click on a new link and have it send an email through their default email client with information already filled in, how do I do this? How would I do it if I wanted an email to be sent out when a new ticket was submitted in the help system? ...

Is it possible for a Master page to access Controller properties?

I need to load a HTML wrapper dynamically depending on data that gets populated in the PageController, which is a base class that all other controllers implement. This is the PageController: public class PageController : Controller { protected PageConfiguration PageConfiguration; public string WrapperTop { get; set; } publ...

ASP.NET MVC eurl.axd errors

Using the following steps: (I have checked this similar post, which does not solve my problem.) Under Windows Server 2003/IIS6, I create a new site called "testapp" In VS2010, I create a new ASP.NET MVC 2 application. I add a view called "Info" with the following code: <h2>System</h2> <h3>Request</h3> <% foreach (string key...

ASP.NET MVC - Wordpress Style URLs

Wordpress is very highly regarded and proven to follow good practise which in turn facilitates rankings with search engines. One proven factor is the seo freindly urls. Such as the examples below; www.myblog.com/test www.myblog.com/another www.myblog.com/contact Lets say that we have two controllers, each with their won actions; Vie...

MVC AJAX action link not updating properly

I'm having a bit of trouble using AJAX action links. Whenever a link is clicked, the UpdateTargetID container is not updated unless the link is clicked twice (which throws an exception on the 2nd click, since the item has already been deleted; after this exception, the page updates). Also, on the first update, the entire page is reloade...

Dropdown client-side validation in IE7, using Html.ValidateFor() helper

I have a weird issue regarding validation of dropdowns on my form. One drop down is a list of states and is decorated with RequiredAttribute: [Required(ErrorMessage="State is required.")] Inside the view, the dropdown and its validation are defined as: <%: Html.DropDownListFor(m => m.State, new SelectList(BusinessLayer.UsStates.GetL...

Why is ModelStateToTempData Attribute from MVCContrib not working?

I'm simply trying to pass the ModelState from one action to another in the same controller, for validation purposes. However, the model state does not get updated. I see that TempData["__MvcContrib_ValidationFailures__"] contains the ModelStateDictionary from the forwarding Action, but I assumed this should get transfered into my current...

asp.net mvc querystring param

i call page like host/home/controller/id. now in view i want to get 'id', i do it like this ViewContext.RouteData.Values["id"] is any other short way? ...

What is causing this error? Error executing child request for handler 'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerWrapper'

I can't figure out why I might be getting this error. It happens on an ajax call. Any help is appreciated. Thanks! This is the full error text: -- 6/21/2010 6:09:10 PM -- System.Web.HttpException (0x80004005): Error executing child request for handler 'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerWrapper'. ---> System....

Entity Framework : updating one-many relationships for an entity's child collection

Consider an application dealing with houses and pictures. An entity named House has a 1:n relationship to HousePicture. The application allows the user to create and edit a House, and add/remove HousePictures. [HttpPost] public ActionMethod Edit(House h) { //get an attached entity from the DB first. House original = db.Houses.Sin...

How to attach a description to each ActionMethod in a Controller (ASP.net MVC)?

So recently, I came up with a way to dynamically build a nav-bar menu where the Controller (And its Index ActionMethod) would be listed in a horizontal bar at the top of each page (via Site.Master) but also based on the user's assigned roles. Each Controller listed would also list (in a vertical drop-down) the ActionMethods available to ...

Accessing array values from a Form in an ASP.NET MVC Controller

In the controlle,r I have this code: var result = Request.Form[0]; where result has a value of 123,test,12,45,12/23/2010...etc.. How can I store each value in one variable? ...

DotNetOpenAuth TwitterConsumer "Failure looking up secret for consumer or token."

Hi, Using DotNetOpenAuth 3.4.3.10103 when i call: public static XDocument GetUpdates(ConsumerBase twitter, string accessToken) { IncomingWebResponse response = twitter.PrepareAuthorizedRequestAndSend(GetFriendTimelineStatusEndpoint, accessToken); return XDocument.Load(XmlReader.Create(response.GetResponseReader())); } I keep getting "...

Why does moving classes into a new folder in Visual Studio break things?

I have an ASP.NET application with three areas. In the root of the application is a Models folder containing a hodgepodge of classes, including two DataContexts, some Repository classes, some ViewModel classes, some helper classes, and some business logic classes. I'd like to create subfolders for each of these subcategories and move t...

Custom 400 redirect based on MVC Controller

Is there a way to override the default 400 redirect (set in web.config) on a per-controller basis? Say I have an Admin controller and an Account controller, each has a custom AuthorizeAttribute. There are two different login forms, and I need the admin controller to redirect to it's when AdminAuthorize attribute is false. ...

How would you guys overcome this issue? Jquery + ajax + server timeout

Hi I am using asp.net mvc, C# and jquery. My site is uses ajax heavily. This has lead to a problem and I am not sure how to fix it( well fix it better than my current solution). Scenario. User logins into my site - cookie set, server has timeout of 30mins User walks away for 30 mins User comes back and clicks on one my ajax enabled j...

Using ASP.NET MVC 2 to display joined record

I'm building out a simple simple ASP.NET MVC 2 page. Was able to do the Edit page the way I want, but am having some trouble with the Index page. I have a table tblContacts that is joined by another table tblStates, database is normalized so the contact table (name, phone, address, city, etc) has a StateId which references a tblStates ...