asp.net-mvc

How to change a model property from a javascript function inside a view?

Hello, Is there any way to alter my Model properties from a javascript function inside a view? Specifically, I have an edit view and need to access a string property value with function SomeJSFunction() { var somevar = '<%=Model.Property %>'; ... then do some changes on somevar and set the model property to the changed s...

ASP auto share on facebook and twitter

How to share automatic news releases and news on Facebook and Twitter from my portal. ...

MVC2 Partial View - Code behind

I'm creating an MVC2 site which is a new, refreshed version of a site built in Web Forms. Due to the nature of some of the features and the a database of statistics and their structure there is no one-size-fits-all way to display some of the information needed to be displayed. Thus, despite following MVC principles elsewhere, in one fe...

a good tutorial for .Net development with MVC, spring.net and NHibernate

Hi all, I'm coming from a php world and am now initaiting a project in .NET environment. After looking around, I noticed that the combination of MVC, spring.net and NHibernate might work for me. In PHP I created applications using Symfony (with propel or doctrine) that combined all these in one framework. The Jobeet tutorial ( http://...

MSBuild flattens the folder structure.

Hi, I'm trying to copy my Views folder for my MVC project in an MSBuild task, but it keeps on flatten everything, and I've tried loads of different things, but never manage to get it to work. Do you have any idea? <ItemGroup> <ViewsFolder Exclude="*.cs;*.svn-base;" Include="../MyMVCProject.Web\Views\**\*.*"/> </ItemGroup> <Cop...

Check if collection is empty or not

public ActionResult Create(FormCollection collection, FormCollection formValue) { try { Project project = new Project(); TryUpdateModel(project, _updateableFields); var devices = collection["devices"]; string[] arr1 = ((string)devices).Split(','); int[] arr...

How do I use Windsor Container in a different assembly but same application?

From what I understand about Windsor Container and MVC applications, is that there should only be one instance of the container and it's usually registered in Global.asax for the running life of the application. I've separated out my business layer in to a separate assembly from the web application and obviously I can't get to that inst...

ASP.NET MVC2 Inject Javascript to masterpage from partial control

I'm moving my script references from < head> in the master to bottom right before < /body>. This has caused some problems with my load order. In my master I have a ContentPlaceHolder, and I can use this fine from my Views to add additional javascripts. But how can I add javascripts to this section from a PartialControl? If I just inc...

Is there a way to prevent a plain text section of an MVC view from rendering?

I have a web application I'm working on, and I'd like to avoid the clutter of if/elseif/else in the view, and of having way too many separate ascx files just for conditional inclusion in a view. What I want to do is create some sort of simple class that works like so (an example will demonstrate what I'd like to achieve) <% using(Requi...

MVC Controller.OnException for different result types

I'm trying to find the ideal exception handling strategy for my MVC project. I have done the following and am looking for some feedback. Problem: I have disparate result types (Pages, Partial Pages, JSON, Files, etc). Controller.OnException() doesn't have an easy way to identify what kind of result the client is expecting. Without anyt...

How do I set up the validation of a class across 2 screens?

I have a class, employee, in which the user inputs values for the properties on one screen, and then some more on another screen. The problem I have with this is how to validate these properties? If I put validation attributes for the properties of the class I have a problem. The validation takes place whether the field is displayed on t...

ASP.NET MVC Three Tier - what's everyone else doing?

When I start work on a new web application I tend to reach for the same tried & tested architecture of ASP.NET MVC, BLL (consisting of a set of services that contain all business logic) and a DAL (consisting of a set of repositories that facilitate the unit of work pattern over something like EF/*Linq to SQL*). The controllers talk only...

Put build number in web.config

I'm trying to get my build number into the web.config of an ASP.Net MVC project (long story, but there is a reason)... something like this: <appSettings> <add key="version" value="1.0.3936.27150" /> </appSettings> Right now, I'm doing it with an executable on the post-build event by looking at the assembly to get the version and s...

Why [PassparametersDuringRedirectAttribute] gets the value of an id from the session and disregard the one in the url?

I am using [PassparametersDuringRedirectAttribute] with an action in the controller. The action takes an id as parameter. After a redirect to another action that also takes an id I found a problem. The problem is that if I called the url for this action with the id in the url the action will disregard the url id and retrieve the id from ...

ASP.NET MVC 2: Session or TempData in Master Page?

I have a div in my master page that is only displayed if Session["message"] contains data: <% if (!String.IsNullOrEmpty(Session["message"].ToString())) { %> <div id="sessionMessage" class="sessionMessage"><%:Session["message"].ToString()%></div> <% } %> I use it to pass general info to users for both acti...

Forms authentication on MVC always redirects to logon

I have forms authentication on my MVC site and the default route is set to send users to /home/index. Home/index is excluded from the login requirement, via a Web.config location section. if I type in http://Example/home/index, I go to the home page as expected, but if I just do http://Example, I get redirected to the logon page. If I t...

Teamcity is not copying all the folders.

I've now setup a MSBuild script to create the folders and files I need in the right structure for my MVC project. I'm then setting Teamcity up to look at the folder with only the files I want to have and copy that to the artifacts folder. So far, so good! However, There is a few folders in the structure that are empty, and Teamcity does ...

Where is the best place to put validation logic given this application design?

Consider an ASP.NET MVC 2 web application project that uses EF4 POCO entities and the repository pattern to store information in a SQL Server database. So far there are 3 projects, 4 if you count the database: 1.) Domain.dll, has no dependencies, exposes POCO's and repository interfaces. 2.) Storage.dll, depends on Domain, implements ...

Performance monitoring for ASP.NET MVC2 ?

Hello, I would like to know if there is an equivalent of "New Relic RPM" or "JavaMelody" for ASP.NET MVC2 ? I can't find anything about monitoring on ASP.NET MVC2... Any idea ? How do you monitor the performances of you ASP.NET MVC2 applications ? http://www.newrelic.com/ http://code.google.com/p/javamelody/ Thank you ...

asp.net MVC authentican for iphone and blackberry app

I am working on an asp.net mvc rest webservice for traffic updates. This web-service will provide information for an iphone and blackberry application. Users need to log in to store things like their favorite routes and to create new routes. What type of authentication should be used? I am thinking of basic authentication where i give...