I'm struggling to mesh two best practices together:
Using DataAnnotations + ModelBinding for validation in ASP.NET MVC 2
Using DTOs instead of domain entities when passing data via the ViewModel
If I want to pass over DTOs instead of domain entities, then leveraging DataAnnotations + ModelBinding for validation would require me to sp...
I'm trying to use jquery.Ajax to post data to an ASP.NET MVC2 action method that returns a JsonResult. Everything works great except when the response gets back to the browser it is treated as a file download instead of being passed into the success handler. Here's my code:
Javascript:
<script type="text/javascript">
$(docum...
Hi all fellow programmer
I'd like to have a separate js file for each MVC set I have in my application
/Controllers/
-TestController.cs
/Models/
/Views/
/Test/
-Index.aspx
-script.js
And I'd like to include the js in the Index.aspx by
<script type="text/javascript" src="<%=UriHelper.GetBaseUrl()%>/Test/Js"></...
Trying to figure out how to adequately test my accounts controller. I am having problem testing the successful logon scenario.
Issue 1) Am I missing any other tests.(I am testing the model validation attributes separately)
Issue 2) Put_ReturnsOverviewRedirectToRouteResultIfLogonSuccessAndNoReturnUrlGiven() and Put_ReturnsRedirectResu...
hi i defined one class to create cookie by received parameter's from user. when i want to add cookie to context i receive an exception.
My Class
public static class ManageCookies
{
public static void Create(string name, string value)
{
HttpCookie cookie = new HttpCookie(name);
cookie.Value = value;
c...
All,
I'm learning MVC and using it for a business app (MVC 1.0).
I'm really struggling to get my head around exception handling. I've spent a lot of time on the web but not found anything along the lines of what I'm after.
We currently use a filter attribute that implements IExceptionFilter. We decorate a base controller class with th...
Hi guys
Just wondering if its possible to get the status of a request from another request?
To help provide some context, I want to use ajax to upload some files to the server. When the upload is started I want triggered another ajax request that checks to see how much of the file has been uploaded (or in other words how big was the o...
I'm building my first ASP.NET MVC website, and I'm trying to figure out how to implement a 404 page.
Should I create a controller called "404Controller?" If so, how do I then register this Controller with IIS so that it redirects 404s to that page? Also, in a situation where something is not found (in the database, for example) by some...
I just found the IUI project on google code where you can build websites that look like iPhone apps.
I have an asp.net MVC website already built. When a user clicks on my website from an iPhone, i want to redirect them to another page that is targeted to the iPhone.
how can i do this detection and redirection?
...
Following the Post-Redirect-Get pattern as described in various spots but maybe in most detail here by Stephen Walter, I want to use RedirectToAction but it does not accept a parameter for sending an object to it. I can only send route values either as an object or as a RouteValueDictionary. So currently I send object ID and type and pul...
i have a partial view with a dropdown in it. the code looks like this:
<%=Html.DropDownListFor(x => Model.Exercises, new SelectList(Model.Exercises, "Id", "Name", Model.SelectedExercise), new { @id = "exerciseDropdown", @class = "autoComplete" })%>
the issue is that i want to reuse this partial view in multiple places but i want to ...
Hi,
I am looking for some examples of how to do model binding in ASP.NET MVC2 for COMPLEX objects.
All the exmples I can find are of simple objects with no child collections or child objects.
If I have an Expense object with a child ExpensePayment object.
In rails, child objects are rendered with the HTML name attributes like this:
...
I'm using asp.net MVC 2 and Ninject 2.
The setup is very simple.
Controller calls service that calls repository.
In my controller I use inject to instantiate the service classes with no problem. But the service classes don't instantiate the repositories, giving me NullReferenceException.
public class BaseController : Controller
{
...
I'm looking for some feedback on my ASP.NET MVC based CMS application architecture.
Domain Model - depends on nothing but the System classes to define types. For now, mostly anemic.
Repository Layer - abstracted data access, only called by the services layer
Services Layer - performs business logic on domain models. Exposes view mode...
Here is my jQuery code:
$.get('/Home/GetList', function(data) {
debugger;
$('#myMultiSelect').val(data);
});
Here is my controller code:
public ActionResult GetList(int id)
{
int[] bodyParts = _repository.GetList(id);
//how do i return this as an array back to javascript ??
...
I put a breakpoint on the controller action but it never fires. Is there anyway to catch errors on a jquery post?
here is my jquery javascript code:
<script type="text/javascript">
$(document).ready(function() {
$('#commitExerciseButton').live('click', function() {
$.post($("#exerciseForm").attr('action'), ...
Sorry for this dumb question on Asynchronous operations. This is how I understand it.
IIS has a limited set of worker threads waiting for requests. If one request is a long running operation, it will block that thread. This leads to fewer threads to serve requests.
Way to fix this - use asynchronous pages. When a request comes in, the...
Is there a sample application to demonstrate best practices for Asp.Net? I am looking for something like SharpArch (for Asp.Net)?
...
As Phil Haack explains on his blog entry, the Route Debugger helps visualizing your routing tables.
My site however gets it's routing injected by the MVCTurbine dependency injection (using Unity) like so:
public class DefaultRoutRegistration : IRouteRegistrator
{
public void Register(RouteCollection routes)
{
routes.Igno...
Hi, I'm not sure how to use composite key.
My Categories table has CategoryId (PK,FK), LanguageId (PK,FK), CategoryName
CategoryId | LanguageId | CategoryName
1 | 1 | Car
1 | 2 | Auto
1 | 3 | Automobile
etc.
I'm following this design
The default action looks like
//
// GET: /Cat...