asp.net-mvc

PageMethods with ASP.Net MVC

I have found ASP.Net PageMethods very handy and easy to use, but I have just started developing using MVC and am not sure how to use them? What is the equivalent of PageMethods.MyFunction() in MVC where MyFunction is a Controller action? I know I can use the Json function to return a value, but how do I call the action from the client...

Good and full implementation of RSS feeds in ASP.net MVC

I've seen a few examples of RSS Feeds in ASP.NET MVC, like this, and some samples in projects (like Oxite), but none of them are complete. Eg. None of them check for the header If-Modified-Since in the request, to save bandwidth. I do not want to reinvent the wheel, so I stop here asking for some directions. ...

How can I include css files from an MVC partial control?

I'm using ASP.NET MVC and I have a partial control that needs a particular CSS & JS file included. Is there a way to make the parent page render the script and link tags in the 'head' section of the page, rather than just rendering them inline in the partial contol? To clarify the control that I want to include the files from is being ...

Inheriting from ViewPage

Is it possible to inherit from both ViewPage and ViewPage<T>?? Or do I have to implement both. Currently this is what I have for ViewPage. Do i need to repeat myself and do the same for ViewPage<T>?? public class BaseViewPage : ViewPage { public bool LoggedIn { get { if (Vi...

How would you implement StackOverflow's profile page in ASP.NET MVC?

I'm guessing the StackOverflow code has something along the lines of a UsersController that defines a function like this: public ActionResult Profile(string id, string username, string sort) { } From what I can tell, there's two ways to go about implementing the Profile function. One is to use a switch statement on the sort param...

Manage ADO.NET Entity Framework ObjectContext in ASP.NET MVC

I'm using ADO.NET EF in an MVC application. I'm considering putting the ObjectContext inside HttpContext.Current so that all logic in the same request can access to it without having to open/destroy each time. However, I'm really sure if it's a good way to manage ObjectContext instances. I have 2 questions regarding this need: As Ht...

Adding title in contentplaceholder adds second empty title tag

My master page has a contentplaceholder in the head tag. Because I want my page's title to represent the function of the current page and because I want the title to be translated in the user's language I have added a title tag in the page's head's contentplaceholder. All jolly and good except that now there appears a second, empty titl...

How to use Data Annotation Validators in Winforms?

I like the Validation Application Block from the Enterprise Library :-) Now i would like to use the DataAnnotations in Winforms, as we use asp.net Dynamic Data as well. So that we have common technologies over the whole company. And also the Data Annotations should be easier to use. How can I do something similiar in Winforms like Steph...

Permissions within views in ASP MVC

I understand that you can use forms authentication to grant/deny access to certain pages based on the criteria of your choosing. However I wish to go in a little more specific than that and say, have different buttons appear for users based on thier permissions. I know I could do something like if(((User)ViewData["CurrentUser"]).IsEmp...

Strange caching(?) problem with ASP.Net MVC.

Hey all, Having an odd problems with ASP MVC deployed on IIS6 (Windows 2003). I've simplified the controller code to the below; <AcceptVerbs(HttpVerbs.Get)> _ Public Function CloseBatches() As ActionResult ViewData("Title") = "Close Batches" ViewData("Message") = Session("Message") Return View() End Function <AcceptVerbs(H...

jQuery in an ASP.net MVC application using Master Pages

I am trying to get simple jQuery to execute on my Content page with no luck below is what I am trying to do: <asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server"> <script src="../../Scripts/jquery-1.2.6.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function(...

Controllers handle application flow, so where does my business logic go?

I will begin this question by admitting I am very new to MVC. The design pattern makes sense to me at a high level, but now that I'm exploring ASP.NET MVC, some of the architectural pieces are challenging my preconceived notions. Learning is a good thing. I've been working with Oxite lately as a learning tool written by people at the co...

ASP.NET MVC route question

I have two routes I want mapped in my ASP.NET MVC application /User/Login /User/{userid}/{username}/{action} (e.g. /User/1/blah/profile) Here are the routes I've defined: routes.MapRoute( "Profile", "Users/{userID}/{username}/{action}", new { controller = "Users", action = "Profile" } ); r...

Custom Error handling in ASP MVC

I want to go beyond the default error handling given in ASP mvc. I have an errors controller, so I can hopefully give different error messages according to whats happened: i.e Invalid arguments, Permission denied, OMG DATABASE DEAD, etc. But I cant seem to work out how to do this, this is what I have tried: [HandleError(View="/Errors/...

Unit Testing Application_Start

I am looking for any kind of information (prefer Moq) on how to unit test the Application_Start method in Global.asax. I am using ASP.NET MVC and trying to get to that elusive 100% code coverage! The fact that I'm using MVC is not the point. And saying that not testing Start is not necessary isn't really the answer either. What if I ...

Best place to place Domain objects in an ASP.NET MVC App?

I'm just starting my first project in ASP.NET MVC. In my webforms experience, I would usually have a separate project dedicated to my domain layer. In here, I would have my Domain specific objects along with my NHibernate mapping files and some business logic. Most of the examples I am seeing online are putting these classes along with b...

What is ASP.NET MVC?

Can anyone explaine me, what is MVC, why we use it and how we can use it. Benefits of using this? and can we use ASP.NET MVC in ASP.NET 2.0 (VS 2005) ...

Best way to filter domain objects for json output in an ASP.NET MVC application

If I'm rendering a regular view in asp.net mvc the only domain object properties that show up in my page the ones I specifically write out. For example: <div><%= Customer.FirstName %></div> However, if I serialize a domain object for json it will include every property. Example: public JsonResult Customer (int? id) { Customer cus...

Windows Live ID in ASP.NET MVC

Hi, does anyone know is there a way to implement Windows Live ID authentication into your ASP.NET MVC site. There is some info about OpenID implementations and it uses some libraries. So is there a way to implement Live ID or it is not yet supported. Thank you ...

HTML.CheckBox(string) evaluates to two HTML elements instead of one

The code <%=Html.CheckBox("SendEmail") %> evaluates to two HTML elements when it's rendered <input id="SendEmail" name="SendEmail" type="checkbox" value="true" /> <input name="SendEmail" type="hidden" value="false" /> Is this by a bug? Or by design? If it's by design, why? ...