asp.net-mvc

Getting the current user entity in ASP.Net MVC

I have this code sample: <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %> <% if (Request.IsAuthenticated) { %> Welcome <b><%= Html.Encode(Page.User.Identity.Name) %></b>! The catch is I am putting the user's id and not name into the 'username' field: User user = _userRepository.Get(...); FormsAuthent...

Expire content in ASP.NET MVC 1.0

Hello, I have ASP.NET MVC 1.0 application (.NET 3.5) running on II7 in 'Integrated Pipeline' mode. To cache/expire content, OutputCacheAttribute can be used to cache the action method's output. OutputCacheAttribute will send same output next time the action method is requested AND set response headers. Please tell, how do I expire cont...

lightweight Asp.net mvc based cms

looking for a cms written in asp.net for company project collaboration dotnetnuke is very heavy weight looking for something simple like blog engine .net but with forums wiki (and or social networking features) any recommendations? ...

asp mvc: specifying a view name does not change the url

I have an create action in my controller for the HttpPost. inside that action I insert the record in the db, and then return a view specifying a different action name, because I want to take the user somewhere else, such as to the details view of the record they just created, and I pass in the current model so I don't have to re-load th...

asp mvc: database calls and caching, introducing a 4th entity?

Here's the architecture of my app: I have a data access layer in a seperate assembly, with a class containing methods such as List_XYZ, Insert_XYZ, Update_XYZ etc. All methods return or use objects from an object model I've created, which also resides in the data access layer assembly. Inside my mvc app, I've created views, controller...

Jquery: Loading GoogleMaps by Ajax gives blank screen

Hello, I am using Jquery to get googlemap data and load it into a div. My googlemap comes from the MVCMaps control which is located on a usercontrol. My code is as follows: $.get('<%= Url.Action("GetMapHtml", "Post") %>', function(data) { $('#MapWndCont').html(data); }); My controller method: public ActionResult GetMapHtml() {...

Render ASP.NET MVC string to View without HttpContext or ControllerContext?

I need to render an ASP.NET MVC view to a string so as to be able to send it via an email (it is an order confirmation email defined in an .ascx file ). I've successfully been able to render an ASP.NET MVC View to string using one of the methods in this question. However now I need to be able to do it via a WCF service (that will be ac...

Show Google maps based on the address in MVC/jquery

I need to show the google map based on the address of a contact in my asp.net (MVC) c# application. I have a list of contacts in my application. When the user views a particular contact, i need to show the google map of the contact's address, to the side of contact view page. How can i implement this functionality using jquery in MVC? ...

How do i stop mvc pop-up login appearing by default on webpage when user is non active or not in aspnet_Users table

Our application in MVC displays a prompt (windows dialogue) pop-up for username and password when user is non active or not in aspnet_Users table. I want instead to redirect to a page in the app with a message, its an internal Intranet app. I'm thinking perhaps a configuration setting somewhere as opposed to code sulution, any ideas? th...

How to cache the result of $.post-request in jQuery?

I have a small jQuery script that gets information by looking at an ID. What is the best way to prevent that the same data are requested more than once (e.g. what's the best practices for caching in jQuery)? I have tried to use $.post and $.ajax with option "cache" set to true, but the request is being sent more than once. Is it bette...

Having Entity Framework trouble

I'm trying to add a ProfileProperty into the ProfileProperties table using ObjectContext.AddObject. The db fields for the ProfileProperties table are: ProfilePropertyID ProfilePropertyDefinitionID UserID PropertyValue The db fields for the ProfilePropertyDefinitions table are: ProfilePropertyDefinitionID PropertyName The variables...

Location of HtmlHelper instantiation for ASP.NET MVC

I am trying to debug a problem where HtmlHelper is null in extension methods. Oddly the debugger claims it's fully populated, however I consistently get null exceptions. I'm trying to figure out where HtmlHelper should being instantiated in an attempt to see where my problem may be. Where should HtmlHelper be Instantiated? Update: I...

Adding a URL Fragment to an MVC ActionLink

here is part of my code this <%= Html.ActionLink(Model[x].Title, "Index", "q", new { slug = Model[x].TitleSlug, id = Model[x].PostID }, null)%> produces this url http://localhost:61158/q/is_there_another_indiana_jones_movie_in_the_works/4 but I want to produce a url with a fragment, like this: http://localhost:61158/q/is_there_an...

Is there any way to re-use editor & display templates in asp mvc applications?

We're developing 3 asp mvc applications, all will require some of the same shared editor & display template views. Rather than copy/paste these across all 3 projects, is it possible somehow to put them in a shared component and reference them somehow in all applications? ...

News section with ASP.NET MVC

I have developed a news page for a website in ASP.NET MVC and its URL being localhost/News. For this purpose I have developed a controller, model, and a view that iterates over all items in a model and displays them. This page displays all the News available in database in descending order of date. I have used routing News/{id} for displ...

Invaid cast exception, even when I have an implicit cast operator defined (in asp mvc app)

I have an mvc model class created and one of the properties is of type 'MyObject'. It also has a System.ComponentModel.DataAnnotations.StringLength attribute on it. MyObject as implicit cast operators so it can essentially be used as a string: public static implicit operator string(MyObject o){...} public static implicit operator MyOb...

ASP.NET MVC 2 RC client side validation not working

I can't seem to get any client side validation working on a MVC 2 RC app. My model has the following: public class ExampleModel { [Required(ErrorMessage="Test1 is required")] [DisplayName("Test1")] public string Test1 { get; set; } [Required(ErrorMessage="Test2 is required")] [DisplayName("Test2")] public strin...

Argh! Why does System.Web.Mvc.HandleErrorInfo get passed to my views?

I'm experiencing a rather frustrating problem. My MVC site runs fine for the most part, but randomly throws an error (which shows a friendly error to the user). When I check the logs, this is what I get: System.InvalidOperationException: The model item passed into the dictionary is of type 'System.Web.Mvc.HandleErrorInfo' but this dicti...

ASP.NET MVC - Easy way to update the strongly typed view, when model adds additional fields?

Existing Model, Controller and View, all working well. Due to a requirement change, there is suddenly a change in the db schema, need to add a few new fields. Database is updated, model (ADO.NET Entity) is refreshed from database and new fields are picked up. Controller is OK since it is working with the "set" and keying off the PK. ...

Resources for learning ASP.NET MVC 2.0

What are some good resources for learning ASP.NET MVC 2.0 (if I don't already know ASP.NET MVC 1.0)? ...