asp.net-mvc-2

S#arp built from the trunk - problem with Microsoft.Web.Mvc

Hi, I’m not sure if i’m doing this the right way so i’m reaching out for a little help...there are some new features in the trunk that I want to take advantage of in my current s#arp project. I’ve downloaded the project from the trunk and run the go.bat file which succeeded, i then took the DLL files from the ‘build’ directory and over...

MVC unittest: access Project.Tests base dir

How do I access the current project directory in a unitest? I would like to test a controller that accesses user generated files. In the controller, I use Server.MapPath("~/Uploaded") which works great. However, that doesn't work for the unittest. I understand that I probably have to mock HttpContext.Server.MapPath but to what? Do I ...

LINQ issue when deployed to WinHost.

I have a relatively simple ASP.net MVC 2 app that is using SubSonic. Everything seems to work well locally, but when I deployed it to WinHost, I keep getting an exception like so: System.TypeAccessException: Attempt by method 'DynamicClass.lambda_method(System.Runtime.CompilerServices.Closure, System.Data.Common.DbDataReader)' to access...

ASP.NET MVC Image Load on Refresh

Hi Guys, I am trying to figure out how to do a server ASP.NET MVC Image Load on Refresh. Basically, I have an array of image's I would like to rotate on refresh on the page. I know how to do this in jQuery but the problem is that all images load at the same time [which sucks in terms of performance] Does anyone know how I could do this...

S#arp ActionLinkForAreas + Parameters + custom routes - UPDATED!

Does the ActionLinkForAreas link extension work with parameters + custom routes? I have a route that exists matching my action which is: routes.MapRoute("Profile", "profile/{artist}/{action}", new {controller="Profile", action="Index"}); But when I call ActionLinkForAreas like this: <%= Html.ActionLinkForAreas<ProfileController>(x =...

How do I implement custom Principal and Identity in ASP.NET MVC?

I want to store extra information in the authenticated user so that I can have it easily accessible (like User.Identity.Id, for example), instead of just the name, since I'm planning on having that non-unique. So far I've gathered that I should look to implement custom Principal and/or Identity, but I'm not sure how to go about it. I'v...

Targeting Mobile and Desktop Browsers - ASP.NET MVC2 with MS Web Application Toolkit and Sencha Touch

I'm building a web app that I'd like to: Use the native UI capabilities of mobile devices (e.g. iPhone, Windows Mobile, Android phones) when rendered on those devices Render nicely on non-web toolkit browsers (i.e. desktop browsers) such as IE, Firefox, Opera My research so far has brought me to using the following technologies: AS...

SubSonic3 SimpleRepository Relationships Generated are Wrong

I have been told that it's more than likely my database that is setup wrong causing the problems so below are my tables with key fields and queries. CREATE TABLE Presentations ( Id INT NOT NULL IDENTITY(1, 1), SpeakerId INT NOT NULL, CONSTRAINT PK_Presentations PRIMARY KEY (Id), CONSTRAINT FK_Presentations_Speaker FOREI...

Populating properties on my Model with values from a SelectList when I post

I'm building an Asp.net MVC 2 application. I have an entity called Team that is mapped via public properties to two other entities called Gender and Grade. public class Team { public virtual int Id { get; private set; } public virtual string CoachesName { get; set; } public virtual string PrimaryPhone { get; set; } ...

jQuery autocomplete fires multiple times

So I have a jquery autocomplete on a testbox that searches the database for a user, and places the ID in a hidden input field. For some reason the autocomplete fires when they type something, then again when an item is selected, changing the text. Since I'm searching first and last name it doesn't find any matches the second time and c...

How can I make HandleErrorAttribute work with Ajax?

In my ASP.NET MVC 2 application I use HandleErrorAttribute to display a custom error page in case of unhandled exceptions, and it works perfectly unless the exception happens in an action called by Ajax.ActionLink. In this case nothing happens. Is it possible to use HandleErrorAttribute to update the target element with the contents of a...

Problem returning ViewModel from edit

Hi, I trying to return the same model back to the view that edited the model. Making it sort of like Word or something with ctrl+s functionality for saving the mode. This works fine though the model that is returned to the view contains a bunch of nulls for some stupid reason. Is it because things were not serialized properly when the c...

Vb.net syntax for EditorFor template?

I'm trying to create my own templated helpers but I got stuck on TextBoxFor syntax. In C# its: <%= Html.TextBoxFor(model => model) %> And I cannot figure out (or google it) - how to write that in vb.net? ...

How do get the current url in a renderaction

When I get the current url in a renderaction using Request.Url.ToString() It returns the url of the renderaction and not the page. Is there a way to get the current url of the page? ...

ASP.Net MVC 2 Area, SubArea and Routes

I have been looking around for a solution for my problem. Found alot of similar issues, but none of them led to a solution for me. I am trying to register an Area within an Area. This works however it "partially" screws up my routing. My route registrations in the order they are registered, consider the FooBar and Foo registrations to...

Issues with Entity Framework Self Tracking Entities and ASP MVC .NET and Managed Extensibility Framework

BIG EDIT: This problem is probably being caused by MEF! I'm using a service oriented architecture and have all my MVC controllers perform actions through the services. I have a base service that looks like this: public abstract class BaseService { protected MyObjectModel context; public BaseService() { co...

Cleaner way of conditionally rendering part of a view in asp.net mvc2

I have an inline style I want to apply to a partial view based on a parameter passed in to it via the ViewDataDictionary. My ascx look like this - <div <% if ((bool)ViewData["Visible"] == false) { %> style="display:none;" <% } %>> ... </div> Is there a cleaner way to do this? Edit: Just to clarify, this is a partial view which is...

Custom ASP.NET MVC ActionResult is not executed

I've used the PermanentRedirectResult from here to perform 301 redirects in ASP.NET MVC 1. Since upgrading to 2.0, the 301 response is no longer sent. Instead, a 200 response containing just the class name is sent. Setting a breakpoint indicates that the ExecuteResult method on PermanentRedirectResult is never called. Apparently the fra...

Automatically set property after component creation with Autofac

Here is the example code: public interface IService<TEntity> { IContext Context { get; set; } //unimportant methods bool Validate(TEntity entity); void Add(TEntity enttity); } public class UsersController : Controller { private IService<User> _service; public MyController(ISe...

Masking Textbox without affecting Model value in ASP.NET MVC

I need to mask the input box/text box in ASP.NET MVC 2 for Credit Card. But the masking shouldn't affect its binding to its model. I am trying to do something like this: [DataType(DataType.MaskedCreditCard)] similar to: [DataType(DataType.Password)] ...