asp.net-mvc

asp.net mvc JavaScript in View User Controls rendered through regular browser request and AJAX request

I have this code in some of my ASCX files: <%=Html.ActionLink(Resources.Localize.Routes_WidgetsEdit, "Edit", "Widget", new { contentType = Model.ContentType, widgetSlug = Model.Slug, modal=true}, new { rel = "shadowbox;height=600;width=700", title = Resources.Localize.Routes_WidgetsEdit, @class = "editWidget" })%> Take note of ...

Why is Html.DropDownList() producing <select name="original_name.name"> instead of just <select name="name">?

I have an editor template whose job is to take a SelectList as its model and build a select element in html using the Html.DropDownList() helper extension. I'm trying to assign the name attribute for the select based on a ModelMetadata property. (Reason: on post-back, I need to bind to an object that has a different property name for th...

Migrating an ASP.Net-MVC Application to a New Server

So basically, I developed this ASP.Net MVC application on a Windows 7 box with Visual Studio 2008. It works well on the local machine, and I was able to host it in IIS no worries. I then decided to upload it onto subversion, and fetch it on a different Windows Server 2008 machine. I downloaded it, had the IIS document root point to my ap...

Using delegates to render html blocks in asp.net

I thought of a neat hack this morning, probably not original, but I haven't seen it before. I don't consider it good practice, but can help when you need to render a block of code repeatedly around your page, and don't want to touch other code or create other files (partial views or components). In your .aspx file create an anonymous d...

Linq to Entities: Next Value in Sequence

im working on a LINQ to Entities project for school, i am working with a db2 database that generates key values through a generated sequence eg. INSERT INTO STUDENT VALUES(NEXT VALUE FOR STUDENT_NUM, 'Raphael', 'Joasia'); is the there an equivalent to the NEXT VALUE operator in LINQ to Entities that will do the same or will i need to c...

How to Use Captcha in asp.net mvc

can any one tell me how to use captcha in asp.net mvc? is there any need to download any control for it? Thank You. ...

ASP.NET MVC - how to replace %20 with dash?

I made a simple form that contains the NAME and some other fields. When user submits form, the following route will be called: ~/Profile/NAME If user entered John Smith as NAME, my URL will be: ~/Profile/John%Smith And I want it to be: ~/Profile/John-Smith The application will display user details and again the same form at the top of ...

Determine the view count like in youtube using Asp.net MVC

Hi, Do anyone knows how to do the View count for a specific page. Like in youtube, when you click a video, the number of view count will increment. But if you already viewed the video before it will not increment. I would like to know how to do this in asp.net mvc. I already have an idea but im not sure if right. I need an expert ad...

ASP.NET cms and display template - 2 projects or just 1?

This is a ASP.NET MVC beginner question (I'm in phase of developing NerdDinner)... I have assignment to create ASP.NET MVC cms (with its own design) and portal (also with its own design) that will display data that's being handled by CMS. I was wondering if I will have to make two individual projects in Visual Studio or I will have to us...

Validating bool property mapped to int in MVC and Entity Framework

Hello I'am using MVC 2 with Entity Framework (the newest that came with VS2010 RC) and have the following problem: Due to compatibility reasons the example User entity in the database contains field called "Disabled" which is the type of int with values 0 or 1 (to be mapped to bool). In my edmx mappings this field is called 'disabled' a...

Save files in database with entity framework

I have an ASP.NET MVC solution built on Entity Framework with Microsoft SQL Server 2008. I need to create a function that lets my users upload files. What I would like is: A solution that uses the Entity Framework to store files in the Database A solution that detects and prevents from uploading the same file twice via some kind of h...

xVal Causing NUnit to Crash when checking ModelState.IsValid

I am trying to run a simple test on a controller in MVC. This controller validates the input using xVal and DataAnnotations. When I run the test (using NUnit via Resharper, NUnit standalone or TestDriven.Net) it crashes the runner with no decent error message. In the event logs it just has a fairly generic .NET Runtime 2.0 Error Repor...

MVC ListBoxFor raises "value cannot be null" exception

I am trying to use the Html.ListBoxFor helper to show a list box and return the selected Id. Is there a problem with the dataValueField not being a string? If the SelectList contained in the model uses integers as the dataValueField then I get a "Value cannot be null - Parameter name: Source" exception raised when the list is rendered i...

How can I show image file from Amazon S3 in asp.net mvc?

Hi all, I need to show image(thumbnail) in view page using controller/action.(like: /Image/Thumbnail) I can send image file that is stored locally by calling the method in controller. // sample code public FileResult Thumbnail() { // get image Stream outFile = System.IO.File.Open("c:\\test.jpg", FileMode.Open); // send ima...

[Bind(Exclude="ID")] doesnt work when i declare it as parameter ?

Hi, If i declare the Bind attribute as a parameter on the method, it doesnt work as it expected [AcceptVerbs(HttpVerbs.Post)] public ActionResult Create([Bind(Exclude="ID")]int ServiceId, Event evnt) { var service = dbSrc.GetAll().WithID(ServiceId).SingleOrDefault(); if (service == null) But if...

How can I break up a controller in ASP.NET MVC while preserving the controller name?

I'm working on a controller that is a part of a very flat hierarchy of pages, and it looks like one section of the site could have over a dozen action methods, not including their corresponding post actions. Is there a good way to break this controller up while still preserving the section name? I don't want that controller class getti...

Multiple AppDomain with Web-based Management Consoles

Hi everyone, I am thinking about a system that is based on plugins. I am going to create my plugins in each AppDomain and talk with them via Name Pipes in WCF. But I also want each of my plugins have some sort of management console in asp.net mvc and one management console for my system. How can I implement such a system? So they are o...

Ajax actionlink on page load

Basically Im building an ASP.NET MVC Application. I have a search page. Its searches for results from a number of different sources. To aid in the speed of page load I decided to load the results from one source first then to dynamically load more results as it finishes searching other sources. So far I have the first set of results re...

Displaying ViewData in a View

What I need is to display Area_Name in various links within my view. Rather than repeat the same loop below each time, can I assign Area_Name to a variable and then display that variable in each link within my view? ViewData filterContext.Controller.ViewData["Categories"] = from m in _dataContext.Categories where m.Area_ID == SectionID...

OutputCache controller attribute vary by user role? Is this possible in .net MVC?

Is it possible to output cache controller actions differently based on user role? or if they are authenticated or not? ...