asp.net-mvc

How to return Nested PartialViews (including their javascript) from an AJAX call in ASP.Net MVC

I have created a treeview of Categories using nested partial views: my Index page (that displays the treeview): <div> Category Menu: <input type="button" value="1" name='selectCat_btn' /> <input type="button" value="2" name='selectCat_btn' /> </div> <!-- Treeview --> <% Html.RenderPartial("ItemCats_UL", Model); %> <div id="CatSe...

Custom Authentication asp.net MVC

At what point should I be checking for my cookie in my mvc app? Basically what I wish to do for each request is check to see if there is a cookie and if so show their name on the screen somewhere if not and the page requires the user to be logged in redirect them to a login page. I DON'T want to use FormsAuthentication as I wish to cre...

ASP.Net Architecture regarding seperation of layers in large projects

Currently in the early stages of developing a very large project using ASP.Net MVC. At present we are using the standard format (Ie Folders for each of the Models/Views/Controllers) Allready I am starting to see a large codebase that has the potential to multiply 100x over and for the sake of future maintainability i'm considering movin...

Asp.Net Mvc Unittesting a controller action

I have the following action that Im trying to unit test: [AcceptVerbs(HttpVerbs.Post)] public ActionResult Default(ProductsViewModel model) { var locationId = model.LocationId; var locationText = model.LocationText; return locationId > 0 ? Summary(locationId, locationText, 1, "Date", true) : View(); ...

Do DataAnnotations only work with EntityFramework/Linq2Sql Classes ?

Hi, Im using Preview 2 of the ASP .NET MVC Framework. Im trying out DataAnnotation attributes with my own NHibernate models but they dont seem to work. I was under the impression that the validation is supposed to get triggered by the model binding during a post. But even thou my model binds perfectly with wrong data supplied by me, t...

How to change Culture?

Hi! Sorry my very poor english ... I'm using asp.net control toolkit to do a calendar on asp.net mvc, and it works fine! But it is in english format date. How can i change to pt-BR culture? I read lot of sites, but i couldn't implement on my project. Anyone could put a link to show me a valid implementation about culture? And why put...

ASP.NET MVC Route All Requests

We need to present the same site, with a different theme (and different data) depending on the "route" into the site. www.example.com/Trade www.example.com/Public NB: These are not dynamic themes which the user can pick. Certain customers will be coming via a third party link which will always point them to one of the urls. The valu...

ASP.NET MVC 2 DataAnnotation based Validation conflict with LINQ2SQL

ASP.NET MVC 2, gives a good functionality of annotation based validation, but to use this functionality I need to reference two files (Microsoft.Web.Mvc.ModelBinders.dll and System.ComponentModel.DataAnnotations.dll) as described here I use LINQ2SQL, to create my entities. And it uses it's own annotations within Entity classes, which n...

How to stream an MP3 from an ASP.NET MVC Controller Action

Hello, I have an mp3 file in my site. I want to output it as a view. In my controller I have: public ActionResult Stream() { string file = 'test.mp3'; this.Response.AddHeader("Content-Disposition", "test.mp3"); this.Response.ContentType = "audio/mpeg"; return View(); } But how do I return the ...

Help with jQuery voting system. Trouble updating html vote count.

Hi all, I'm trying to create a Stackoverflow like voting system, and I've run into a slight problem. I have the following HTML that has jQuery onClick events wired to it: <div id="c_<%=Html.Encode(Model.C.cID) %>" class="votes"> <img src="../../Content/gfx/Up.png" class="up" alt="" /> <span class="votecount"><%= Html.Encode(M...

asp.net mvc and jquery trying to pass in list

i have a strongly typed asp.net-mvc view and the Model has a .Links property. Links is an array of link, which has a URL, a Description and an ID. i have a bunch of links. Every links has a list of tags and those tags are layed out like this: <a id="98" href="www.ibm.com>IBM</a><b class='dblclick'>Tags: Software</b> <a id="99" href="...

Return 307 Temporary Redirect in ASP.NET MVC

Is it possible to return a 307 Temporary Redirect from a controller in ASP.NET MVC? I sometimes need to re-POST the values submitted from one form to another URI. Using JavaScript to do the selection on the client side (thereby bypassing this issue) is not an option. Redirecting via a GET is not an option as posted data includes an 8k...

Custom Authorize attribute not working on expired ajax requests.

Hi. I have a custom authorize attribute on my controllers and it is not being called on expired ajax requests. I'm using forms authentication, and call controller methods via $.ajax (jQuery). The ajax request returns my login page and I don't seem to be able to intercept this. Thank you. UPDATE: I figured out why: I commented the auth...

Asp.Net MVC load a partial view using ajax from a JQuery UI tab

Hi I have several action methods on my controller that return a partial view (ascx), and I want these partial views to be rendered when clicking on the different JQuery UI tabs. The tabs are defined like this: <div id="tabs"> <li><a href="#FirstTab" title="First tab">First tab</a></li> <li><%= Html.ActionLink("General", "General",...

Does having multiple web front ends and a single database back end fit into the MVC design pattern?

We have 3 websites at the moment that all operate off the same database backend and they share almost 100% of the business logic. It is becoming a pain to have to update 3 website's code every time to accommodate a small change. Would using ASP.Net MVC work for us? What I am thinking is the business logic and database is almost identic...

Unit Testing HtmlHelper that Needs to Access Data Layer

I am trying to create a unit test for an HtmlHelper that accesses my data layer to get a string. I have looked at a lot of posts around this and I am probably missing something. The problem that I am having is how do I mock the access to my data layer? I usually do my dependency ijection through the constructor, but I cannot here beca...

Actions in ASP.NET MVC

Hello, When typing in my URL SalaryFor/Microsoft/Balmer i need to display salary for user with name Balmer and if I type in URL SalaryFor/Microsoft i need to display salary for all employee in Microsoft company Is it possible? because when I use this link SalaryFor/Microsoft/Balmer all works fine public ActionResult Salary(strin...

Accessing resources via Uri in Asp.net mvc

I am working on an ASP.NET MVC web application in which I have an object with a Uri property. The Uri contains a restful link to a resource in the following form: /Repository/Dataset/5 The Dataset action of the Repository controller returns the contents of dataset 5 as Json. How do I call this method from the Uri and interpret the re...

how do you pass in a selector into jquery editable plugin

i am trying to pass in a selector into the ID variable but this doesn't seem to work as it blows up at runtime. what is wrong with the below syntax ? <script type="text/javascript"> $(document).ready(function() { $(".dblclick").editable('<%=Url.Action("UpdateSettings","Photos", new { id = $(this).attr("id") }) %>', { ...

ASP.Net MVC 1.0 Web Hosting

I am developing a website using ASP.Net MVC 1.0. Can i host that website on a server having ASP.Net 2.0? Because my hosting provider supports only ASP.Net 2.0. Does anyone know how to host a website developed using ASP.Net MVC 1.0 in a web server supports ASP.Net 2.0 ...