Questions tagged [asp.net-mvc-3]

18889 questions
1

votes
2

answer
4.3k

Views

NUnit testing MVC Controller returns null View

My HomeController.Index() action works (in normal operation), but under NUnit testing, the ActionResult (ViewResult) that is returned always has a null View and ViewName. Here are the tests I am running (condensed into a single method for ease of reading). I am using Moq, NUnit, Castle.Windsor Th...
twehr
1

votes
3

answer
1.5k

Views

Resource cannot be found for content inside of theme folders

My project has a feature to override views and content, if they exist, from a themes folder. The path to the themes folder will vary by site, so my folder structure looks like this: Themes\ SiteA\ Content\ Images\ logo.png screen.css Views\ Home\ Index.cshtml I am able to successfully override the d...
Mathachew
1

votes
2

answer
6.4k

Views

Additional parameters for TextBoxFor() in ASP.net MVC3

I was using a textbox to do the following: This basically shows a textbox which is disabled under specific circumstances. I decided to replace this with a more 'mvc-friendly' way. @Html.TextBoxFor(m => model.value1, new { id = 'blah' }) But not sure how to add in the disabled attribute (Dynamically)...
JustAnotherDeveloper
1

votes
4

answer
7.3k

Views

Access denied when uploading files to folder using asp.net mvc 3?

I'm currently studying asp.net mvc 3, and right now I'm trying to implement a application where a user can upload a file to a folder: Here's the first implementation that I have and it's actually working fine, here is the controller code: public class FileUploadController : Controller { // // GET: /...
Randel Ramirez
1

votes
1

answer
184

Views

Prevent Last 'N' password reuse - MVC 3

I have a login form that I created in MVC 3 which has a 'change password' view. At the moment there are no restrictions with respect to reusing previous passwords. I understand that I'd need to create a custom password manager as ASP.net has nothing out the box for this. I have a 'previousPassswo...
lacoder
1

votes
1

answer
90

Views

MVC - There is no ViewData item of type 'IEnumerable<SelectListItem>' that has the key 'UserType' [duplicate]

This question already has an answer here: The ViewData item that has the key 'XXX' is of type 'System.Int32' but must be of type 'IEnumerable' 3 answers enter image description here Server Error in '/' Application. The ViewData item that has the key 'UserType' is of type 'System.String' but must be...
shihabmohamed
1

votes
0

answer
41

Views

Sending of Email failed in the Deployed Web Application

Good Day, My working module returned a catch exception error: THE REMOTE SERVER RETURNED AN ERROR: (401) UNAUTHORIZED. AT SYSTEM.NET.WEBCLIENT.DOWNLOADDATAINTERNAL(URI ADDRESS, WEBREQUEST& REQUEST) AT SYSTEM.NET.WEBCLIENT.DOWNLOADDATA(URI ADDRESS) Although i have stored the credentials in the web cl...
Karlord
1

votes
1

answer
235

Views

MVC5 : The resource cannot be found

I am fetching data from a table and displaying it. Every row in the webpage will have a edit hyperlink. That pops up a edit window for respective row. The contents of the pop up are replaced by the @Html.Partial() function. now the form gets submitted from the Partial view. The Interesting fact is f...
Dikesh Kumar
1

votes
0

answer
32

Views

MVC OutputCaching - why should not use page directive?

Reading Output Caching of MVC. As per the site, Don't use the page directive in an MVC view. This directive is bleeding over from the Web Forms world and should not be used in an ASP.NET MVC application. I can understand we have used OutputCache in ASP.NET. But why the same should not be used in MV...
Karthick Raju
1

votes
1

answer
33

Views

Redirect to custom view in case overall page takes more than 30 seconds in MVC

I have a MVC view which is rendering multiple partial views and two action. In this scenario sometime we face page unresponsiveness issue. So Can I implement any action filters type solution based on overall performance of View? Basically I want to redirect to a custom page whenever this view takes...
S.S.
1

votes
0

answer
97

Views

Writing Excel using EPPLUS not workable after deployed

I'm using EPPlus to generate excel (.xlsx) in my mvc3 web application. It works fine with my localhost. However, after i deployed to the server, the excel file return as an Excel Binary Workbook. Can anyone help me? Here is how i generate my excel (.xlsx): ExcelPackage pck = new ExcelPackage(); Exc...
1

votes
0

answer
28

Views

ViewStart.cshtml is not getting rendered in Custom View Engine

I have defined my custome view engine as below just to add more locations to search for. public class CustomViewEngine : RazorViewEngine { private static string[] AdditionalViewLocations = new[] { '~/{1}/{0}.cshtml' }; public CustomViewEngine() : base() { MasterLocationFormats = MasterLocationFormat...
Parashuram
1

votes
1

answer
37

Views

data table view is not refreshing properly jQuery ajax MVC call

I am trying to filter the data from a table in MVC application using jQuery ajax call. Below is the code, function getAllUserRoleCompany() { var url = '@Url.Action('GetAllUserRoleCompany', 'UserRoleCompany')'; Var Organisation = ''; $.ajax({ url: url, data: { Organisation: Organisation}, cache: fals...
pankaj bawdane
1

votes
1

answer
391

Views

MVC Error while loading view: Error.An error occurred while processing your request

I am working on MVC application which has many views. Some of them are working fine. And another view gives me an error: An error occurred while processing your request. An application was working fine before nothing has changed recently and suddenly it has started showing the above error. In my web...
pankaj bawdane
1

votes
0

answer
37

Views

MVC post not getting the updated value of a mvc textbox, when we change the content of a txtbox via jquery in client side which is copied from a pup

We have a MVC textbox(orignal textbox) in our form that expects time formatted string(eg:10:30), and we have provided a normal button next to it that opens a pop-up and user can see another textbox inside that which can be used for entering time in decimal format(eg:10.5) then the pop-up shows the...
pvaju896
1

votes
0

answer
21

Views

How to fix issue when entering www.sitename.com/ROBOTS.TXT in URL only refreshes the page

I have a site that's about to be taken down in month's time. What I need to do is place a robots.txt to prevent the search engine from indexing it any longer. However, after I placed the file on the root of the solution in the web server, and tried to check if I can access it by typing www.sitename....
Warren
1

votes
1

answer
30

Views

DateDiff equivalent in Linq MVC

Im currently working on a date comparison page and a co-worker of mine gave a SQL Query that I need to convert on a Linq. but Im not that familiar with DATEDIFF in SQL So Here is the SQL Query ,case when DATEDIFF(day, isnull(a.NewWorkerDate,a.Workerdate), a.Workerdate)=0 then 'NEWWORKER' ELSE 'OL...
Enrique Gil
1

votes
1

answer
31

Views

How can call dynamic id in JavaScript for another url action click?

My HTML code is here: @Html.DropDownList('Statues', (SelectList)ViewBag.UserType, string.Empty, new { @class = 'NewIDCn',@id = 'name1' }) Update @Html.DropDownList('Statues', (SelectList)ViewBag.UserType, string.Empty, new { @class = 'NewIDCn',@id = 'name2' }) Update and my script is here, $(documen...
A.Jafor
1

votes
0

answer
18

Views

Static class not found in Webform report master in production

I am using following This tutorial to call mvc partial pages in webform. this is working fine in dev and production but i have a backup deployment on another server with same configuration. but is giving me following error. Unable to load one or more of the requested types. Retrieve the LoaderExcep...
Zia
1

votes
1

answer
1.4k

Views

ASP.NET MVC save new record verse update existing record conventions

I'm working on my first ASP.NET MVC (beta for version 3) application (using EF4) and I'm struggling a bit with some of the conventions around saving a new record and updating an existing one. I am using the standard route mapping. When the user goes to the page /session/Evaluate they can enter a new...
Paul Mrozowski
1

votes
1

answer
1k

Views

Asp.Net-MVC application dying

I have a strange issue with an Asp.NET MVC application. Using Asp.NET MVC 3 Preview 1 on IIS 7.5 - Integrated After building the application everything runs fine. Then after some random amount of time (or sometimes after updating a view or js file) the application dies. Meaning, requesting the root...
jhorback
1

votes
1

answer
232

Views

ASP.NET MVC 3 in production?

Now that ASP.NET MVC 3 is in beta, and ready for 'go-live'. Would it be safe to use in project, although not prevented I am curious on security, performance and ease of upgrade to release version.
Dustin Laine
1

votes
1

answer
178

Views

I need authentication advice for an ASP.NET MVC 3 application

I have a web application that will be used by the public. This application has a login credentials requirement. I don't want to create yet another site that you have to create a custom username/password combination unless you really want too. I would like to support 3rd party logins like Facebook...
Jim
1

votes
1

answer
858

Views

ASP.NET MVC Override HandleError causes View to not render

In my app I'm using 'HandleError' whereby if an error happens, my 'Error.vbhtml' view renders. This is working great, except now I want to also log the error. I've built a custom HandleError Class, Inherited the HandleErrorAttribute, and Overridden the OnException method. Now my error gets logged,...
Chase Florell
1

votes
1

answer
3.1k

Views

Razor view engine RenderSection

I am really digging this new Razor View Engine... For someone just coming from another web platform the new MVC 3 efforts are starting to feel right at home for me... My question is about sections, I see it is possible to define sections in your layout and inject content into them but from all the s...
JBeckton
1

votes
1

answer
648

Views

Why isn't my EditorTemplate firing?

Here's the item from the View @Html.EditorFor(Function(model) model.BirthDate) Here's the code from the EditorTemplate (simplified) @ModelType Date? @Html.TextBox('', Model) but the output doesn't have the span tags. The datatype of the model.BirthDate is Date? The folder structure is Views Shared E...
Chase Florell
1

votes
1

answer
1k

Views

Caching a call to Html.Action

I try to cache a call to an action method in ASP.NET MVC3 RC1. The caching works, but the variation by parameter doesnt seem to pick up. Is there something I can do to make the 3 calls to HotOffers return different results depending on productID? The output right now is Hot offers 4 Hot offers 4 Ho...
Mathias F
1

votes
1

answer
2.1k

Views

Cannot add Controllers to Castle.Windsor in ASP.NET MVC

Given the following setup, I have three assemblies. Web (ASP.NET MVC 3.0 RC1) Models Persistence (Fluent NHibernate, Castle.Windsor) This is my ControllerInstaller. using System; using System.Web.Mvc; using Castle; using Castle.Windsor; using Castle.MicroKernel; using Castle.MicroKernel.SubSystems;...
Ciel
1

votes
1

answer
781

Views

Is IHierarchicalEnumerable the prefered way of dealing with hierarchical data?

I'm building an asp.net mvc app, I want to build up an hierarchical structure, is IHierarchicalEnumerable and IHierarchyData the best way to implement a hierarchical structure?
Marcus
1

votes
1

answer
904

Views

Repository.Update strategy using EF4 Code First?

I'm working on an MVC site with Entity Framework Code First, using Ninject for DI to the controllers, and I've run into a design question. I've seen two methods used for updates with Code First. The first uses a 'get by id,' changes the values of the object returned, then calls Context.SaveChanges...
Dean
1

votes
2

answer
2.7k

Views

How to render an HTML attribute from a Razor view

I would like to use the same partial view for create, edit, and details views, to avoid duplicating the fieldset structure for an entity. Then, depending on which view renders the partial view, I would like to add a class of 'read-only' to a div surrounding my fieldset and handle making the actual...
ProfK
1

votes
2

answer
658

Views

Using jQuery to load Telerik MVC scripts

I'm busy building my first MVC app that uses the Telerik MVC components. Their docs specify that the ScriptRegistrar helper be called right at the bottom of a view, e.g. 'at the end of the master page.'. I assume this renders a script block that must only run when the page has loaded. I normally...
ProfK
1

votes
1

answer
1.5k

Views

Multiple validations on a property using FluentValidation

I'm using FluentValidation and ASP.NET MVC 3. I just have a couple of questions regarding the validation. I have my validation on my view model setup like this: public NewsViewModelValidator() { // Title is required RuleFor(x => x.Title) .NotEmpty() .WithMessage('Title is required'); // Title must b...
Brendan Vogt
1

votes
1

answer
1.3k

Views

How to get SINGLE value from ViewBag or ViewData

I have this: _gameService = new GameService(); ViewBag.Data = _gameService.JoinGame(userID, gameID, whoJoin); return View('Game'); This code gets list of users that are ingame, and pass it to game view. Nothing fancy. On the game view I need to get single values from ViewBag in diffrent places,...
Łukasz Baran
1

votes
1

answer
2.5k

Views

MVC Partial View not returning model on ajax postback

I have a view which has a partial view in it, which has a text box in it. The main view has a model of type person and the partial view a model of type person.other. When I do a ajax post back the other model is empty, I expected it to pick up the textbox data. This is the code; Classes public cl...
user415394
1

votes
2

answer
1.7k

Views

Linq 2 Sql DataContext Update Issue During Fetch/Edit/Update Workflow

In many of my ASP.Net MVC 3 action methods, I'm having some serious issues with trying to update a record (or set of records) resulting in the following exception: An entity can only be attached as modified without original state if it declares a version member or does not have an update check polic...
beaudetious
1

votes
1

answer
3.2k

Views

ASP.NET MVC3 IIS6 Allow Domain Users to Access Site but Another User Connecting to Database

MVC 3 (probably the same for 1 & 2), Server 2003, IIS 6, .NET 4, SQL Server 2005 I have a simple admin app that only 2 or 3 people will ever log into, so I don't want to bother with Forms Authentication, separate username/pw and all that. I want to simply have the user log in with their existing AD...
Dzejms
1

votes
1

answer
916

Views

N2 CMS and MVC 3 RC causes "The current request for action 'Index' on controller…is ambiguous…'

I've used N2 CMS for a while now, I've just updated to use MVC 3 RC and I'm now recieving this error on every page: The current request for action 'index' on controller type 'HomeController' is ambiguous between the following action methods: System.Web.Mvc.ActionResult Index() on type Project.Web.Co...
Ash
1

votes
1

answer
625

Views

How to validate a dropdownlist populated from the database in ASP.NET MVC3?

I have 2 tables, Person and Nationality. Person has an FK to the Nationality table via NationalityID. In my Create Person form, I've got a dropdown that's populated with NationalityID and NationalityDescription. What's the best way to validate this dropdown to deal with people using developer toolba...
Dave
1

votes
3

answer
597

Views

Is a good idea use Membership Provider with ASP.NET MVC

In ASP.NET MVC we dont have Login controls of webform, then still make sense use Membership Provider? It is a good practice?
Felipe Fujiy Pessoto

View additional questions