asp.net-mvc

ASP.NET MVC with Pipes & Filters Pattern. Benefits ?

Hi everyone, I'm just about to start a new project on ASP.NET MVC using LINQ to SQL for ORM. So, I have read and watched various tutorials about best practices and I wonder: What is the benefit on using the pattern Pipes&Filters in my model (have in mind, I intend to use LINQ to SQL). Why just not use repository pattern in the model for...

Model-binding an object from the repository by several keys

Suppose the following route: {region}/{storehouse}/{controller}/{action} These two parameters region and storehouse altogether identify a single entity - a Storehouse. Thus, a bunch of controllers are being called in the context of some storehouse. And I'd like to write actions like this: public ActionResult SomeAction(Storehouse sto...

Application variable refresh in an mvc web app

I have an Application level variable that gets loaded from a database when the application starts. Now when accessing the variable, I check to see if it is not null. If it is not null I use it, if it is null I initialize it from the database, then use it. My question is how can I make sure that this variable is refreshed atleast once a ...

Using Repository Pattern, POCOs and LINQtoSQL with tables of multiple types

Firstly, my previous question will help give some back story. As stated in that question, I have a super-type table (if that is the technical term for it) and I have multiple sub-types in different tables - all with field unique to that sub-type. Events * Id * EventTypeId * AllEventTypes_Field EventType0 * EventId (FK) * EventType0_Fi...

MVC LinkButton equalivalent

I'm rewriting a Web Forms application as an exercise to learn some MVC skills. I have a number of LinkButtons on the original application which postback and raise a serverside event that rebinds data to a datagrid. E.g. Event handlers: protected void lbtnOffset0_Click(object sender, EventArgs e) { Sessio...

ASP.Net MVC: How do you access the session from a different project within the solution?

I have 2 projects in my solution. MVC Web application Class library The MVC Web application references the class library. The class library contains a class that extends the default ASP.Net Controller. I'm putting a variable in session in the application's Global.asax. protected void Session_Start(object sender, EventArgs args)...

RouteLink issues to same action

Hello I have a view that both edits and creates "usergroups". And I have a "usergroup-detailsview" (Admin/Usergroup/43) where I have 2 links: Html.RouteLink("Edit", "UsergroupEdit", new { usergroupID = Model.Usergroup.UsergroupID }) Html.RouteLink("Create", "UsergroupCreate") In my global.asax I got: routes.MapRoute("Usergroup...

ViewModel approach interferes with ModelBinding in MVC 2 when using the new "For" HTML helpers

I am using .net MVC 2.0 and have set up an edit view that receives a custom ViewModel object. The ViewModel is a class with two properties: // Properties public Portfolio Portfolio { get; private set; } public SelectList slSectors { get; private set; } In my view there is a form with the purpose of updating the Portfolio Object. The...

Passing Data Between Views and Controllers

I'm working on an application that manages people and their spouses, if married. Essentially a person will be entered and then from that person I want to be able to add a spouse. My database schema is like this. Persons (Person_ID, Name, BirthDate, etc...), Marriages(Marriage_ID, Husband_ID, Wife_ID, Date). The process is Add a Per...

Getting ASP.NET MVC to correctly escape the # (hash/pound) character in routes

I've got a route that looks like this: routes.MapRoute( "BlogTags", "Blog/Tags/{tag}", new { controller = "Blog", action = "BrowseTag", viewRss = false } ); And I create a URL using that route like this: <%= Html.RouteLink(Html.Encode(sortedTags[i].Tag), new { action = "BrowseTag", tag = sortedTags[i].Tag })%> However, wh...

ASP.NET Impersonation in web.config vs. running the app pool with custom identity

Ok so I'm using ASP.NET MVC. I'm supposed to upload a file and write it to a network share. I'm getting "Logon failure: unknown user name or bad password." when I try to write to the network location. I solved it on my machine by impersonating the file server account, added this to web.config: <identity impersonate="true" userName="xx...

Custom Model-Binder that pulls from a cookie problem?

I am trying to do the following. Use the default model binder to bind an object from query string values. If that fails, I then try and bind the object from cookie values. However I am using dataannotations on this object and I am having the following problems. If there are no querystring parameters the default model binder doesn't...

Is ASP.NET MVC 1 forwards compatible with ASP.NET MVC 2?

Can I run a MVC 1 application using the MVC 2 assemblies without a hitch? I understand that some 3rd party tools have had stuff broken in MVC 2, but let's assume I'm not using those any other tools. ...

How can I set the contentType of a jQuery ajax post so that ASP.NET MVC can read it?

I have some jQuery that looks like this: $.ajax({ type: "POST", url: "/Customer/CancelSubscription/<%= Model.Customer.Id %>", contentType: "application/json", success: refreshTransactions, error: function(xhr, ajaxOptions, thrownError) { alert("Failed to cancel subscription! Message:" + xhr.statusText);...

How do ASPX pages turn into System.Web.UI.Page?

ASP.NET (.aspx) pages have a <%@ Page %> declaration at top that includes an Inherits="" attribute. ASPX pages inherit from System.Web.UI.Page declarative-ly. My question is, what code actually converts the aspx page into an object of type System.Web.UI.Page class? Where in the lifecycle does this take place and what class is responsi...

Building an ASP.NET MVC Master Page Menu Dynamically, Based on the current User's "Role"

I've seen some similar questions, but none that look like what I'm trying to do. This is my current implementation w/out any security: <div id="menucontainer"> <ul id="menu"> <li><%= Html.ActionLink("Main List", "Index", "AController")%></li> <li><%= Html.ActionLink("Product List", "Ind...

Combine ASP.Net MVC with WebForms

Would it be possible to create a MVC root application (Portal with masterpages and themes) and add a couple of WebForms based subprojects (we already have an existing WebForms application that we would like to integrate into the Portal)? How would you centralize navigation (sitemaps, url routing)? How would you share the masterpages? Ho...

How are people using Editor/Display Templates vs. Html Helpers?

Hey guys Just wondering how and when people are using Editor/Display Templates vs. Html Helpers. Specifically I am talking about its use in rendering different UI control rather than rendering entities. For instance, I have something like the following atm: <tr> <th><%= Html.LabelFor(x => x.ActivityTypeId) %></th> <td><%= Html...

extra data required to render a list

how do people deal with extra data needed to render a list. eg I have a IList<User> Users that is a property on my viewmodel. However for each row in the user table, extra information needs to be displayed. should i create a display model for User with the other properties included on it? any ideas would be greatly appreciated? ...

asp.net mvc, wrong function being fired. - EDITED

I have master page that has this control that accepts Post verb. My LogOn page is also tied to the master page. When I enter wrong username/password, method of that control that accepts verb also gets fired along with the method to accept username password. This is on HomeConroller: [ActionName("ControlTemp"), AcceptVerbs(HttpVerb...