asp.net-mvc

ASP.Net MVC routing legacy URLs passing querystring Ids to controller actions

Hi, We're currently running on IIS6, but hoping to move to IIS 7 soon. We're moving an existing web forms site over to ASP.Net MVC. We have quite a few legacy pages which we need to redirect to the new controllers. I came across this article which looked interesting: http://blog.eworldui.net/post/2008/04/ASPNET-MVC---Legacy-Url-Routi...

How do you get a custom msbuild task to work properly?

I have a VS 2008 solution with 2 projects. Project A builds into an assembly that is used by Project B (MVC project). I have created a custom task in Project A, which I call when building Project B. I have come across 2 issues: If my AssemblyFile property points to Project A's bin directory, everything works well. But when I want t...

Serialize MVC ViewDataDictionary

I'm using SQL state server for session variables. I'm also storing ViewData in TempData so I can access the ModelState across a redirect. The problem is that the ViewDataDictionary is not serializable. Is there a way to hook into the session storage logic to serialize the ViewDataDictionary when the Session variable is stored? Thanks...

Using ASP.NET MVC without an ORM

In my ASP MVC application I'm using standard SQL (rather that Linq to SQL or other ORM) to query my database. I would like to pass the database results to my view and iterate over the results in my view. But I'm not sure how to do this. Every example I've seen passes some string or uses L2S. I would like to pass something like neste...

ASP.NET MVC, ActionFilters, static classes and passing data around...

I'd like to hear your opinions and maybe better suggestions for the following scenario: I have define a custom ActionFilter that does some job and comes out with some value. I would like to use that value in controller actions and in models. Now, I could use TempData to pass this value from the ActionFilter to any controller action met...

how do I add a url parameter to a routelink in asp.net mvc?

All, my situation is that I have the basic route, plus some other simple routes: routes.MapRoute( "Default", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = 1} ); So the f...

Is ASP.net Model View Presenter worth the time?

I'm reading about ASP.net MVP pattern over this weekend and it seem like even the most simple task take too much effort if do it in MVP pattern the pay off seem to be at larger project but i think to myself if i'm going to follow MVP. Why not just do the project in ASP.net MVC? The reason that I'm looking at MVP pattern is because I've ...

ASP.Net MVC Simple Edit data from default template

when creating a new View and selecting Edit template, the template will create a textbox for the primary key which is not editable. <%=Html.TextBox("CompanyID", Model.CompanyID)%> So, deleting the control from view, will cause the problem: the collection which is post to controller has the CompanyID=0 , so no edit will be done. But...

ASP.MVC: Implementing a non-templated view engine?

I'm fairly new to ASP.MVC. For our new Web application I'm considering between two options for view engines: Using some of the available view engines (the default one, NVelocity, Brail, etc.) as a primary view code generator. Implementing an application-specific C# DSL for generating HTML code so that the main bulk of the view code is ...

Is it possible to develop ASP.NET MVC with MS Visual C# 2008 Express Edition and IIS?

Is it possible to develop ASP.NET MVC with MS Visual C# 2008 Express Edition and IIS? The tutorial states that 'Visual Studio 2008 or Visual Web Developer 2008 Express' are required. ...

How does DataAnnotationsModelBinder work with custom ViewModels?

Hi, I'm trying to use the DataAnnotationsModelBinder in order to use Data Annotations for server-side validation in ASP.NET MVC. Everything works fine as long as my ViewModel is just a simple class with immediate properties such as public class Foo { public int Bar {get;set;} } However, the DataAnnotationsModelBinder causes a N...

Securing web application on the data access level

Hello! Please consider the following setup: Multi-tenant webapp. Tenants create company accounts and company accounts have user accounts under them. Users have roles, there's a special role "Owner" (the user who created the company account). I'd like to have users to edit other user accounts (some admin tasks), but two conditions mu...

Shared configuration files in .NET

I have a solution that includes both a web and a Windows NT service application. These are of course two different projects but within the same solution. They do however share a lot of the same configuration. Currently I have the same values in both the web.config and the app.config file. This is starting to get messy and I'd like to h...

How do I link to a remote databse with ASP.NET MVC?

I have an ASP.NET MVC application up and running, using a SQL Sever express 2005 database instance that is running on my development machine. When the app gets deployed to production, however, the IIS instance and the SQL Server instance will be on different logical machines. I dont know if they're different physical boxes, but i doubt...

Getting the username inside a model class

I'm trying to implement basic auditing with some of my models (like CreatedAt, UpdatedAt, CreatedBy and UpdatedBy). The date/time part is done. I'm throwing events on my models when a property is changed (implementing INotifyPropertyChanging, INotifyPropertyChanged) and can update the correspondent fields just fine. I just need to know...

Setting up virtual directory when using IIS for ASP.NET MVC debugging

I am trying to use IIS for debugging ASP.NET MVC in Visual Studio. The problem is that if I choose "Use Local IIS Web server" in Visual Studio, I have to choose a virtual directory, something like http://localhost/myapp/ This is a problem because the ASP.NET MVC application is assumed to run from the root directory and the MVC would par...

troubleshoot authentication error

Symptom: Some users cannot successfully POST, most can successfully POST. When the error occurs, users are redirected to the site's Shared/Error page. Technologies used: IIS v6 Windows Server 2003 asp.net v3.5 asp.net mvc framework v1.0 jQuery linq sql server 2005 Authentication: Windows with the AspNetActiveDirectoryMembershipProvider...

How to pass query results with FK relations(EF) to the View

Hi, I am not able to figure out this simple thing in ASP.NET MVC: I have two tables: Customer: CustomerID FirstName LastName AddressID AddressTemporaryID Address: AddressID Street City I have my relations(FK) set in DB and trying to use Entity Framework. My navigation properties(FK) are named Addr...

Asp.Net MVC Call another controller from view

Let say I'm on the page "Home/Index" and I want to go to the page MyOtherController/Index/1 How can I do this ? I try : <%= Html.ActionLink("Test", "Index", "MyOtherController", new { id=item.Id }) %> Did I also have to add a route in Global.aspx file ? ...

Multiple forms in ASP.NET MVC

Context Let`s say i have: In layout Site.Master: <div class="leftColumn"> <asp:ContentPlaceHolder ID="MainContent" runat="server" /> </div> <div class="rightColumn"> <% Html.RenderPartial("_Login"); %> <asp:ContentPlaceHolder ID="SideContent" runat="server" /> </div> Login partialView looks like: <form action="/myApp/...