C # MVC Download the dynamic file name

How can I download a pdf file that's not static. I tried this: public ActionResult GetPdf(string filename) { var invoice = db.Invoices.ToList().Find(x=>x.InvoicePath==filename); return File("~/Invoice/" +invoice.ToString(), "application/

HtmlEncoder Error in Asp.Net MVC 5

I am getting this error when I compile: Error-CS0103 "The name 'HtmlEncode' does not exist in the current context" I am using Visual Studio 2015 Community edition and MVC. The code is: using System; using System.Collections.Generic; using System

How to add and consolidate lines sharing a user name in a list

My project is a game where users try to predict scores of football matches and are awarded points based off of different criteria. I'm using MVC and Entity Framework. I am trying to create a leaderboard that displays the total score for each user. I'

How to do session management in aspnet identity?

I am using Asp.net identity for Login,Register,Forgot Password etc and source code is taken from this below link: http://www.asp.net/mvc/overview/security/create-an-aspnet-mvc-5-web-app-with-email-confirmation-and-password-reset http://www.asp.net/id

ASP.NET MVC Multi-Threading, worth it?

I'm a bit confused, my ASP.NET MVC app will be hosted on a server, so is there any point in making it multi-threaded? For example, if I want one thread to execute my translations, is this a good idea? Can someone elaborate this to me please? I'm a bi

The model does not contain a constructor that takes 8 arguments

Im am completely new to C# and was trying to setup a very basic application where I created the class/model: public class Customer { public int CustomerID { get; set; } public string FirstName { get; set; } public string LastName { get; set; } public

JavaScript validation in form

I have tried to figure this out for ages. The JavaScript gets called but it doesn't invoke the error message. It always shows up as no error even though it should invoke an error message. All the fields shows up as green. I am pretty new at this so t

.net mvc 4 using razor and json

I am currently working on a .NET MVC 4 project. We have a razor list of items, the razor handles number of items shown and the ordering. We want to then make this client side. Is there a way we can update the razor via json to achieve this? Thanks in

Can not open the database when the website is hosted in IIS

When I run my website from Visual Studio it all works fine. Now I am trying to move forward and start testing the multi tenancy part, so I had to move my website to IIS. For some reason I can't get access to the database. The error I get when I open

Unit of work for each module

I am currently building an ASP.net MVC application, which has be broken down into multiple modules (as well as a generic class library). I have implemented a Unit Of Work pattern for my first module. This unit of work class contains a number of diffe

How to check if only one role fits?

I need to filter users by Roles, but all users belong to two Roles Example: Admin and Group1 for one user, and User and Group1 for the other. Now I want to filter them by Group1 Role and ignore Admin and User. public ViewResult Index() { string[] rol

Dynamic typing of a generic class

I have an object that's being automatically serialized by the WebAPI, but I wanted to wrap it to provide context to my data. An example would be: public class SecureModel<T> { public string Info { get; set; } public T Data { get; set; } } This seria

How to change the appearance of a text box

I want to have a multiline textbox of max of 3 rows and I also want to modify it`s width and height size. How can I do that in mvc? The following code is not working @Html.TextBox("myTextBox", String.Empty, new { @style = "width: 150px; ,he

pass html to an asp.net mvc function

I have Html helper method, creating a check box along with some text, I pass. @Html.CheckBoxFor(x => x.SomeProperty,@<text> <ul> <li> </li> </ul> </text>})) public static MvcHtmlString CheckBoxFor<TModel, TPropert

How to avoid multiple messages on MVC3?

A user wants to post in his blog, he fills the field and click submit. The site is running slow, he clicks again, and again, and again. It was finally saved, but now he check his posts and sees 4 posts. How can I prevent this from happening? If the u

Dependency injection frameworks for .Net

Please Suggest an Easy to use DI framework for .net. I am using mvc2.in our project also ASP.NET MVC 2 we using Ninject it is really nice and has a pretty cool name :)

Visual Studio 2008 with SQL Server 2005 Developer Edition

I am trying to add a database to the App_Data location in an ASP.NET MVC 2 application in Visual Studio 2008 (VS). I have SQL Server 2005 Developer Edition installed on the local machine. However when adding the database VS complains that SQL Server

How can I run the controller action method programmatically?

I'm trying to execute a controller's Action Method programatically and I'm not sure how. Scenario: When my ControllerFactory fails to find the controller, I wish it to manually execute a single action method which i have on a simple, custom controlle

Is ASP.NET MVC 2.0 still available?

Does anyone know if this has been released yet? I went to asp.net and the Windows PI installs MVC 2 and it doesn't mention anything about RC's but then Scott Guthrie doesn't mention anything on his blog either.ASP.NET MVC 2.0 RTM was released on 2010

Add rel and title to ASP.NET MVC action links

I decided primarily for SEO reasons to add the "rel" to my action link, but am not sure that the way I have gone about this is going to follow "best practices." I simply created a new Extension method as shown below. Is this the best w

Pass the URL of the website in the Route in ASP.NET MVC

I am working on a project that needs to grab the actual URL and use it in the route itself. Everything I am seeing, reading and testing allows the route to grab the items after the site URL. This is what I have tried and each time it simply say the s