asp.net-mvc

How do I pass multiple objects to ViewPage in ASP.NET MVC?

I think I know the answer, but I would like to bounce around some ideas. I would like to pass several (in this instance 2) somewhat different pieces of data to a View. My initial thought is simply to wrap-up the various objects into a containing object and pass them along that way. Then from the View, I'd have something like var objC...

Why does AuthorizeAttribute redirect to the login page for authentication and authorization failures?

In ASP.NET MVC, you can mark up a controller method with AuthorizeAttribute, like this: [Authorize(Roles = "CanDeleteTags")] public void Delete(string tagName) { // ... } This means that, if the currently logged-in user is not in the "CanDeleteTags" role, the controller method will never be called. Unfortunately, for failures, Au...

ASP.NET MVC Beta 1: DefaultModelBinder wrongly persists parameter and validation state between unrelated requests

When I use the default model binding to bind form parameters to a complex object which is a parameter to an action, the framework remembers the values passed to the first request, meaning that any subsequent request to that action gets the same data as the first. The parameter values and validation state are persisted between unrelated w...

StackOverflowException caused by a linq query

edit #2: Question solved halfways. Look below As a follow-up question, does anyone know of a non-intrusive way to solve what i'm trying to do below (namely, linking objects to each other without triggering infinite loops)? I try to create a asp.net-mvc web application, and get a StackOverFlowException. A controller triggers the follo...

Developing asp.net mvc applications as a team?

I don't know if this has been discussed. Let's say you are in a three developer team. How would you share: models - views - controllers by controllers by use cases something else? Maybe someone says this has nothing to do with asp.net mvc but I think it affects somehow. ...

How do I succesfully host a asp.net mvc app on shared hosting without resorting to ugly URLs?

Let's assume we're talking about the recently released Beta version. Specifically I'm interested in a step-by-step tutorial or similar, and I'd be thrilled with information addressing how to do so on CrystalTech. ...

Should I still see the query hit in SQL Profiler?

I am currently building a web site and I just implemented SqlCacheDependency using LinqToSQL like so. public IQueryable<VictoryList> GetVictoryList() { string cacheKey = HttpContext.Current.User.Identity.Name + "victoryCacheKey"; IQueryable<VictoryList> cachednews = (IQueryable<VictoryList>)HttpCont...

Mocking HttpContext doesn't work

I am trying to mock out HttpContext so that I can unit test my controller's Request.IsAuthenicated call. I am using the code that I found at Scott Hanselman's blog to simulate HttpContext using rhino.mocks. so i have this unit test piece: PostsController postsController = new PostsController(postDL); mocks.SetFakeControllerContext(post...

Is it necessary to have a separate View for each controller action?

Is there a mandatory relationship between a Controller Action and a View? I mean is it necessary to have a physical View (.aspx page) for each Action inside a Controller class? ...

Double/incomplete Parameter Url Encoding

In my web app, my parameters can contain all sorts of crazy characters (russian chars, slashes, spaces etc) and can therefor not always be represented as-is in a URL. Sending them on their merry way will work in about 50% of the cases. Some things like spaces are already encoded somewhere (I'm guessing in the Html.BuildUrlFromExpression ...

ASP.NET MVC URL auto-resolution in CSS files

In normal WebForms scenario, any root-relative URLs (e.g. ~/folder/file.txt) inside CSS files such as: .form { background-image: url(~/Content/Images/form_bg.gif); } will automatically get resolved during runtime if I specify <head runat="server"> In the referencing page. However, that is no longer happening on an ASP.NET MVC Beta...

Best ASP.NET MVC book?

I'm going to be starting a new project with VS2008/ASP.NET, and I would like to use MVC. What is the best MVC book out there? (Are there any good ones?) Edit: I threw in the asp.net-mvc-2 tag so we could possibly get some updated answers. ...

Why is Nant not working with TeamCity?

I have nant set up to build my ASP.NET MVC project and it works fine locally. I add nant to a tools folder and add it to version control. TeamCity picks up my changes and starts the build but it fails. I believe I'm using the latest version of Nant and I have added the .net framework 3.5 to the nant.exe.config. What am I missing on t...

Get MultiView like behavior with ASP.NET MVC

I am trying to build a generic form submission system using ASP.NET MVC. I'd like to make it as easy as possible to create forms with a form view and a "success" view. Using the WebForms method, this was easy and could be accomplished with templates or multiviews. With MVC, I'm a bit stuck. Here's what I'd like to emulate: <% if (formN...

Any page navigation helpers for ASP.NET MVC?

Are there any html helpers for page navigation. eg. if i have 1000 records to display, i want to display the Previous 1 2 3 4 ... etc Next link stuff under the filtered collection. Anyone know of anything out there? ...

Opening a file relative to server folder

When I try opening a file it tries to use "C:\Program Files\Common Files\Microsoft Shared\DevServer\9.0" as the base directory. How can I get the working directory of the web application? ...

Asp.Net MVC JQuery goodness

I've been developing a simple website using asp.net MVC and I'm starting to add some JQuery\JSON goodness. My problem is up until now all my 'Views' have been strongly typed and I've been building the view based on data from ViewData.Model.MyViewsData. Now once the view has been rendered and I do a Ajax style request I get new data b...

What are the best options available for a rich UI in an ASP.NET MVC application?

So far I've found the following components for building ASP.NET MVC views: Yahoo UI (YUI) Ext JS Flexgrid (grid only) What are the other options that are currently available which inlcude a nice grid component? ...

asp.net mvc post to different views in same form

Hi all, I'm an asp.net MVC newbie - very use to webforms! I have form area in my view. If I click button A I want to submit to /Books/1, but if I click button B I want to submit to /Books/2 How do I go about achieving this with MVC? Thanks in advance Nick ...

Security with QueryString values in Asp.net MVC

How do you properly ensure that a user isnt tampering with querystring values or action url values? For example, you might have a Delete Comment action on your CommentController which takes a CommentID. The action url might look like /Comments/Delete/3 to delete the comment with the id 3. Now obviously you dont want anyone to be able to...