asp.net-mvc

ASP.NET MVC ViewResult vs PartialViewResult

What is the difference between the controller result named ViewResult and PartialViewResult? More importantly, when is the PartialViewResult used? ...

How to Implement ASP.Net MVC Interactive Filtering

Here's my desired result: Given a ASP.net MVC page that has a block at the top with several parameters for filtering against a list that is display below, something like... TextBox1 RadioButton1 TextBox2 OtherOptions Here item item item I'd like the filtering to be interactive capable on later iterations or immediately i...

ASP.NET TempData persists between requests

I am using temp data as follow in my controllers - very simple, when there is a problem: TempData("StatusMessage") = "You have no items set to Auto-Ship." Then on every page I have a user control as follows: <div class="error-container"> <% If TempData.ContainsKey("ErrorMessage") Then%> <script> $('div.error-container').show();</scr...

TDD: Help with writing Testable Class

Hello, I have a quick little application and wanted to give a try to develop using TDD. I've never used TDD and actually didn't even know what it was until I found ASP.NET-MVC. (My first MVC app had unit tests, but they were brittle, way coupled, took too much up keep, and were abandoned -- I've come to learn unit tests != TDD). Back...

Restrict access to a specific controller by IP address in ASP.NET MVC Beta

I have an ASP.NET MVC project containing an AdminController class - giving me URls like http://myserver/admin/AddCustomer, http://myserver/Admin/ListCustomers, etc. I want to configure the server/app so that URIs containing /Admin are only accessible from the 192.168.0.0/24 network (i.e. our LAN) I'd like to restrict this controller to...

Strongly typing ASP.NET Controller.View() method for model type

There's no strongly typed View() method to return an ActionResult. So, suppose I have class Edit : ViewPage<Frob> In my FrobController, I will do something like "return View("Edit", someFrob);". There's no checking going on here, so I have to always manually synchronize the view and controller's use of it. This is suboptimal, and I'm...

Strongly typed ASP.NET MVC ViewData extensions - where to put identifiers?

Sometimes the overhead of creating a new model type is annoying. In these cases, I want to set ViewData, and the options seem to be: Simply set viewdata with a string key, and cast it out. This has obvious problems. Store the identifier (string key) somewhere (where? on the controller?) and cast it out on the viewpage. While solving on...

Are iframes/script the only ways to have multiple independent controls in ASP.NET MVC?

Besides using script or an iframe, is there any way to get independently operating views/actions working on a single page? For example, suppose I have a Delete page for FabWidgets. It might look like: Are you sure you want to delete this FabWidget "<%= Model.Name %>"? Careful, this FabWidget controls these FrobNozzles: <% Html.RenderA...

Can an asterisk in the text cause a getJSON request to not work?

This is really strange but this code is working fine unless the value entered by the user includes an asterik (*) or other characters like $ or #. The #ticketNumber.Val() is the suspected problem. Some of our id's have an * in them. Any help would be appreciated. function buttonClicks() { var action = '/ServiceCall/IsAServiceCall...

Html.ActionLink in asp.net MVC object value in wrong format

I have a html.actionlink that i wish to display a link to a members profile page like this: http://somesite.com/members/{username} When use the following markup <%= Html.ActionLink(r.MemberName, "profile", new { MemberName = r.MemberName } )%> I get a link that looks like this: http://somesite.com/members?MemberName={username} What ...

URLs like ASP.NET MVC offers

Is there any way to implement a URL mechanisim in asp.net like it has in asp.net mvc e.g. mydomain.com/user/myusername but without using the MVC if so, how? ...

Using a named route in Form.Begin in ASP.NET MVC

Is there a way to force use of a named route in ASP.NET MVC when using Form.Begin. I'm learning more and more about routing and getting scared that it can be very fragile if you just change the order or whether or not parameters have defaults. <% Form.Begin(...) %> <!-- no overload for providing a route name --%> There does not seem t...

Correct practices for where to put images and static files in an ASP.NET MVC application?

There is a directory in the standard ASP.NET template "Content" where most people seem to be putting in images and css files etc. For instance stackoverflow's logo: actually is refered to with a server path containing 'content' in the URL (just do View Source for any SO page and you'll see this). So they obviously are storing images...

asp.net mvc and css: Having menu tab stay highlighted on selection

Is there a better way to do this? I have an HTML helper extension method that checks if the current tab menu is the the selected one and then chooses .selected css class or not. I put the html.IsSelected link in each li as <li class="<%=Html.IsSelected(string a, string b)%>" > where a is the tab name and b is ViewData assigned. i...

How can I view the ASPNETDB database from a sample ASP.NET MVC app?

A basic ASP.NET MVC app appears to store user info in App_Data\ASPNETDB. How can I view tables in that database using VS2008? ...

Do I need to have a View Page for every Action in ASP.NET MVC?

I have a customer index page that displays customer lists. I have a search functionality within this page and I want the url to be http://mysite/search?id=434 when i perform the search. The index page will also display the search result. Thanks ...

ASP.NET MVC - adding action filters programmatically

Hello, I've been doing a bit of research regarding action filters and wondered if there was a way to add them programmatically to controllers?? To give some context, I'd like to add a logging filter if logging is configured in the web.config, otherwise I don't want the filter to exist in the execution chain of each action method. I ap...

How to design an ASP.NET MVC site for caching with Velocity?

I'm coming from the LAMP world, where the "cache everything" mentality is prevalent. Everything is put in memcache. I'm starting a new project with ASP.NET MVC and SQL Server. I'll probably go with LINQ to SQL or maybe Entity Framework. Are there design decisions I need to make now for caching, or is it easy enough to start using Vel...

Linq To Sql Many-Many Join Table

I am a somewhat experienced Rails developer and I thought I would try out ASP.NET's version of MVC. In doing so I also decided to try Linq->Sql... I am a bit confused about the way Linq->Sql handles joins. A trivial example of my schema is : books: id title categories: id name books_categories: book_id category_id Simply dragging...

ASP-MVC: Object Instance Lost When Redirecting After Authorizing

I have an "Authorize" attribute on the Action that binds the form data. If the user submits the form but is not authorized, the login prompt appears. Once logged in, the user is properly redirected, but the model is null. How to handle this? ...