asp.net-mvc

Send list/array as paramater with jQuery getJson

I have the following where I'm trying to send list/array to MVC controller method: var id = []; var inStock = []; $table.find('tbody>tr').each(function() { id.push($(this).find('.id').text()); inStock.push($(this).find('.stocked').attr('checked')); }); var params = {}; params.ids = id; params.stocked = inStock; $.getJSON('My...

delete cookies using javascript.

I am working on Asp.Net Mvc and am creating a cookie using in one page.I want when a user moves to her page the cookie gets deleted.Further if the same page (in cookie was created) is refreshed the cookie should not be deleted.How can i achieve this. ...

Which ORM supports mapping existing databases?

So I have a layered ASP.NET MVC proof-of-concept application with good separation between presentation concerns, business logic, and infrastructure concerns. Right now it is operating off of a fake repository (i.e. LINQ queries against static IQueryable objects). I would like to create a functional SQL repository now. That said, I don...

Limiting the threads per processor using IIS 7.5

I’m running some performance tests on an ASP.NET MVC application. I see a high contention rate and the number of threads increasing overtime. I believe the two to be related, as threads are blocked new threads are created by the thread pool to handle incoming requests. I believe this in turn is making the contention worse (i.e. more thre...

DropDownListFor does not set selected value

I have a view that is displaying a Drop down list using the HTML helper DropDownListFor <%: Html.DropDownListFor(Function(model) model.Manufacturer, New SelectList(Model.ManufacturerList, Model.Manufacturer))%> My controller is passing the View a ViewModel containing the Manufacturer and the ManufacturerList Function Search(ByVal ite...

How to make a video or audio file HTTP response always download instead of play in browser?

Have some audio and video files that users are to download, however depending on the file type or browser the browser may attempt to play the file instead of downloading it. This is not desired, how can I avoid this? The anchor will be a direct link to the file unless I need to create some sort of Action to handle this properly. I am usi...

% Time in RT Checks counter is very high in an ASP.NET MVC application

I'm currently profiling an ASP.NET MVC application. We're seeing that the "% Time in RT Checks" counter is very high. I understand this means we are passing a lot of time in CAS checks, but I'm having difficultly pin pointing what code is making this CAS checks. We do very little native interop, so it does come from that. What other fram...

How should I implement an Ajax Menu?

My ASP.NET MVC has the need for a vertical navigation menu where submenus would be generated dynamically via ajax when the user clicks on the parent menu item. I would like to use jQuery and Css to drive the menu but that's just a preference. I really don't want to reinvent the wheel here. I know this type of menu has been done before. ...

Dynamically extend SQL statement - page search

In my model I have a string txtSearche with the value coming from a textbox like : "hello all friends" How can I write my statement dynamic adding WHERE text LIKE '%Text%' for each word additional? something like 3 times: WHERE Text LIKE '%@Text%'"; This is my code: string[] wordsFromTxtSearche = txtSearche.Split(' '); SqlCommand...

ASP.NET MVC Routes Mapping issue

Hi guys, I am struggling with generating outbound urls in asp.net mvc 2. Here is the scenario. Controller: MoveController Action: Index() View: Index.aspx Now what I would like is to have multiple urls mapping to same controller (MoveController) and action (Index) with different parameter (locationId) value e.g. url -> Rout...

How do I build a self-referencing Model Object for Hierarchical data in asp.net MVC?

Hello SO, I'm trying to understand how to build a self referencing model for hierachical data. Eventually i will be creating a category tree. I don't anything in tables yet. After I have the structure nailed down then I will create the tables. My existing Object is defined like this: public class Categories { public Int64 catID { ...

Finding an Anonymous Type's Source

I have a reflection method finds all the types in a namespace: var models = Assembly.GetAssembly(application).GetTypes().Where( @t => @t.Namespace == typeof(ViewModelNamespaceBeacon).Namespace).OrderBy(@m => @m.Name).ToList(); My problem is I'm returning an Anonymous type with the name of: {Name = "...

FlowPlayer - error handler firing on one of two machines, same code?

ASP.NET MVC2, framework 3.5 Machine 1: dev box - Win7 Ultimate x64(IIS 7.5), VS2010 Ultimate, Firefox 3.6 Machine 2: dev server - Win server 2003 (IIS 6). Code on the server is compiled from SVN and deployed to the IIS folders on the server by TeamCity. The problem is this: I have a page which shows a video using FlowPlayer. I have a...

Where to write Database and Business logic in MVC?

Hi All, As I am learning and working on Asp.Net MVC application, I want to know that what is the better place to write Business Logic and Data Access logic in MVC. Where should I write DataAccess and Business Logic among three layers (Model, View and Controller) ?? Could anybody please tell me the correct way to write the code for thi...

NHibernate Contextual Sessions in ASP.NET MVC

I want to use NHibernate's Contextual Sessions in my ASP.NET MVC 2 application, but I'm having a hard time finding guidance on how to properly do this. I'm interested in Session per request. ...

Asp.net mvc 2 Search form in Partial View

Hi could someone make a small example for me. I wanna create a partial view with a textbox and a submit button. When the user hits the submit button, I want to redirect to the following url /Search/SearchQuery/ UPDATE //This is my searchBox.ascx <% using (Html.BeginForm("Index", "Search", new { area = "eCommerce" }, FormMethod.Pos...

Issue with <%: ... %> vs. <%= %> when displaying generated text

Hello SO: I am writing an MVC application with C#. In this one particular section, I have a conditional switch for the navigation to highlight the appropriate tab. Here is the code for that: <script type="text/C#" runat="server"> string oController; string oAction; const string current = "class=\"current_page\""; prot...

Reading models into ViewModels and other way round in MVVM - best practice -

Hello guys, I would like to get an insight into your daily work :P How do you read the Person data into the PersonViewModel ? Is it just a PersonViewModel pVM = staticHelper.ConvertPersonToPersonViewModel(person); or is there something cooler? ...

What's wrong with this linqTOsql self referencing object mapping?

Hey there, I'm trying to create a self referencing object using linqTOsql mapping. So far, I am definitely in over my head. Here's the code I have: [Table] public class Category { [Column(IsPrimaryKey=true, IsDbGenerated=true, AutoSync=AutoSync.OnInsert)] public Int64 catID { get; set; } public Int64 parentCatID { get; set;...

How to post form using jQuery?

I have a form with a submit button and it works fine, but I now have a user request to make the form get saved (posted to save action) if a link on the page is clicked and the form is "dirty". I've got the logic in place by having an isDirty JavaScript variable, now I would like to post the form from the JavaScript function when it is d...