Consider two methods on the controller CustomerController.cs:
//URL to be http://mysite/Customer/
public ActionResult Index()
{
return View("ListCustomers");
}
//URL to be http://mysite/Customer/8
public ActionResult View(int id)
{
return View("ViewCustomer");
}
How would you setup your routes to accommodate this requiremen...
I'm developing an ASP.NET MVC 2 application that connects to some services to do data retrieval and update. The services require that I provide the original entity along with the updated entity when updating data. This is so it can do change tracking and optimistic concurrency. The services cannot be changed.
My problem is that I need t...
I have an image folder stored at ~/Content/Images/
I am loading these images via
<img src="/Content/Images/Image.png" />
Recently, the images aren't loading and I am getting the following errors in my error log. What's weird is that some images load fine, while others do not load.
Anyone have any idea what is wrong with my routes...
Say I have a controller called "HomeController" which inherits from Mvc.Controller. Also say I have written the constructor of the controller and some filters for some actions.
Public Class ClientController
Inherits System.Web.Mvc.Controller
Public Sub New()
''Some code
End Sub
<SomeActionFilter()> _
Functi...
Hi,
I am new to MVC and have a grasp of the basic model, but still doing everything with postbacks etc.
One aspect of the UI I want to build is to have a drop-down-list of items with a button to add an item to the database and refresh the list. Achieving this with WebForms was straight forward as everything was wrapped in UpdatePanels,...
I'm not entirely sure if this is the best way to word it, however, I'm having a little trouble working out how to achieve. What I have is a page with a form on for editing a user's details.
The page itself sits on /User/Edit/1234 where 1234 is the employee number.
On that page there is a reset password link which opens the following jQ...
I watched Scot hanselmann's presentation at mix '10. When he presented the tiny urls for Nerddinner he said it was a 2 part process.
a) modify global.asax.cs with a new route
b)some sort of isapi rewrite.
When I implemented this in my asp.net mvc 2 site I only did part a. and it works. why then did he do part b?? what is the advantag...
I have an embedded database in an asp.net mvc project. If I try to write to the file, I sometimes get a write failed exception because the SQL Server can't write to the file. How can I check an ObjectContext, if its writeable, without actually writing something to the database?
...
I use TempData to keep ModelState during redirects (using MvcContrib technique). This works fine. However, in rare cases, user aborts request and then immediate fires another (e.g. quickly clicks on another menu item). This causes ModelState errors to appear on that page, for which it does not belong.
The problem is that TempData is sto...
I'd like to keep my concrete classes separate from my views. Without using strongly typed views, I'm fine. I just use a big parameter list in the controller method signatures and then use my service layer factory methods to create my concrete objects.
This is actually just fine with me, but it got me thinking and after a little playing...
I'm trying to build up a string array in JavaScript and get the results in a string list in the action method. Below is what my JavaScript looks like. I'm using jQuery 1.4.2. The problem is my List in the action method is always showing NULL. Will a JavaScript string array not map correct to a string list in C#?
var test = ['tes...
I have 2 "lists" of (4) radio buttons {value = "0", "1", "2", "3"} in all lists.
The first list needs to drive the second list (which may occur multiple times). So if an option is selected in the first list, the SAME option is selected in the second list. It sounds weird, but it has a purpose. The first list is more of a "select all" ty...
The title pretty much sums it up, it puts the following line of code in:
<% foreach (var item in Model) { %>
As the View is auto-generated and uses reflection to work out exactly what item is, so you get intellisense and everything, I just wonder, why do they use var rather than the actual type?
...
Could someone show me the syntax of an Html.ActionLink that will produce a hyperlink that looks like this:
<a h ref="/mycontroller/myaction/67">mylinktext</a>
thanks.
Terrence
...
I'm using jQuery autocomplete plugin from jQuery website
calling the controller url which return json in return. The problem is the parameter sent to the controller is always null.
Here is the in-browser jQuery code for the autocomplete:
$(document).ready(function() {
var url = "/Building/GetMatchedCities";
$("#City").autocompl...
public class TheController : Controller
{
IThe the;
public TheController( IThe the)
{
//when User.IsInRole("r1") The1 should be injected else r2
this.the = the;
}
}
public class The1 : IThe{}
public class The2 : IThe{}
//anybody knows a good way of doing this ?
...
This question is related to another wiki I found on SO, but I'd like to develop a more comprehensive example of an automated ASP MVC 2 development environment that can be used to develop and deploy a wide range of small-scale websites by beginners. As far as characteristics of the dev environment go, I'd like to focus on beginner-friend...
I read in http://support.microsoft.com/kb/298408 that IIS6.0 automatically responds with a "courtesy redirect" (HTTP 301) on URLs that lack a dot.
When a browser requests a URL such as http://www.servername.de/SubDir, the browser is redirected to http://www.servername.de/SubDir/. A trailing slash is included at the end of the URL. ...
I have the following line in my view:
<div class="editor-field">
<%= Html.TextBoxFor(m => m.Description)%>
</div>
How do I define the width of the text box?
...
In general, I don't like to keep code (BaseClasses or DataAccess Code) in the App_Code directory of an ASP.NET Site. I'll usually pull this stuff out into a MySite.BusinessLogic & MySite.DataAccess DLL's respectively.
I'm wondering should I be doing the same for ASP.NET MVC.
Would it be better to Organise the solution something along t...