asp.net-mvc-2

Base page class equivalent in ASP.NET MVC2? Coming from a webforms background...

Problem: I have a webforms app where every page inherits from BasePage.cs I also have another class AuthenticatedBasePage.cs which inherits from BasePage.cs BasePage.cs has some code which finds out if a Forms Authentication cookie is set, and if so, sets a IsAuthenticated boolean flag and a MyAppUser object (only has properties such a...

How can i do an AJAX post in ASP.NET MVC2?

hello guys what is the best way to do an AJAX post using ASP.NET MVC? ...

how to detect response content-type in asp.net mvc

hi, I've wrote very simple minification/compression handler that minify css and js by indicating request type (Request.RawUrl.EndsWith("css" || "js")), but i don't know an approach to indicate which response type is html and then minify that as HTML-content because in mvc isn't extension to checking. thanks in advance ;) ...

access to article by article name in ASP.NET MVC2

Greetings. How can I make access to my article or post by their name? For example: Like at stackoverflow has access to this question by the name http://stackoverflow.com/questions/3079363/access-to-article-by-article-name-in-asp-net-mvc2 ...

quick FormCollection question ASP.NET MVC2

I have a simple object public class SomeObject { public Int32 id { get; set; } public string name { get; set; } } In a strongly typed view I am letting the user edit SomeObject.name, when the form is posted the receiving method doesn't see SomeObject.id in FormCollection (it does see SomeObject.name). Do I need to actually pl...

Edit Post action - why does respository.save() save the data?

Hi I am a tad befuddled. I can't reason why the following works: AcceptVerbs(HttpVerbs.Post)] public ActionResult Edit(int id, FormCollection formValues) { Dinner dinner = dinnerRepository.GetDinner(id); UpdateModel(dinner); dinnerRepository.Save(); return RedirectToAction("Details", new { id = dinn...

ASP.NET Membership: to be or not to be?

I'm contemplating how I should implement authorization and authentication with ASP.NET and MVC2. Lets refer to this as a user system. I have seen three types of solutions in the wild: Use the built-in ASP.NET Membership system (NerdDinner) Roll your own (Shrinkr) Create an abstraction layer for the ASP.NET membership (Tekpub's mvcstar...

Best practice for http redirection for Windows Azure

I have an azure website which is named: http://myapp.cloudapp.net Of-course this URL is kind of ugly so I set up a CNAME that points http://www.myapp.com to the azure url. All is well up until here, but there is a snag. http://myapp.cloudapp.net has leaked out and now is indexed by google and lives on other sites. I would like ...

Deploy asp.net mvc 2 IIS 7.5 with Visual studio 8 and windows 7 pro

I've got problems when I deployed my mvc website with IIS 7.5. On my solution in VS 2008, I published web to an specified folder. Then I go IIS version 7.5 create a virtual directory to my published folder then convert it to web application. When I run it http://localhost/myMVC my flash can't specified file , when I type http://local...

Model vs Input Validation for MVC 2 .NET

Hello, mvc 2 comes wit built-in support of Model validation but how do i do "input validation". for example i have an interface of creating memo where i have populated the view with dynamic checkboxes corresponding to employees. The validation is straight forward i.e do not submit if no checkbox is selected. i wonder if there is a way o...

mailTo in asp.net MVC 2.0

Hello, how can I use mailto in asp.net MVC 2.0 Website. <a href="mailto:[email protected]"><b>Simple MailTo</b></a> I must get email from Model. I need something like this: Html.MailTo(Model.item.email) Thanks. ...

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 do you create an HtmlHelper outside of a view in ASP.NET MVC 2.0?

We are in the process of upgrading an ASP.NET MVC 1.0 application to the 2.0 release and some of the code requires the use of LinkExtensions which require an HtmlHelper to render. While we know that some of the code doesn't follow the MVC model correctly and are in the process of recoding as needed, we need something to work so get the a...

Unit testing an MVC project with EF?

Hello! I am trying to start unit testing an MVC2 project, which uses the Entity Framework. When I run my "hello world" test, it fails saying this: The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid. How can I pass the connection data (w...

How to control the html element id and name when using MVC2's EditorFor helper

I'm curently refactoring my MVC2 code base to use the ViewModel approach versus. As a result, the models I'm =passing to my views to render forms now look like model.TheObject model.TheCollectionOfOtherObjects I'm trying to use the HTML.EditorFor helper to render a Template Editor for a data type. It used to work when I was trying t...

How to pass post/route values to jQuery Ajax POST request?

Trying to ajaxify "favorite this song". The way I understand it, it is desirable to separate javascript from the markup completely to an external .js file. However, we require to pass id of the song along with the ajax post. We have the following markup <div id="favorite-song"></div> The way I would have done it using ASP.NET ajax ...

WCF Data Services SaveChanges(): "Resource not found for the segment"

My line ctx.SaveChanges(); in my controller DutyController.cs throws the following exception when I try to edit my Duty object. System.Data.Services.Client.DataServiceClientException: <?xml version="1.0" encoding="utf-8" standalone="yes"?> <error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"&gt; <code></code>...

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...

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....