Questions tagged [asp.net-mvc-5]

1

votes
1

answer
173

Views

Where is the ClaimsIdentity information stored after calling AuthenticationManager.SignIn() using CookieAuthenticationProvider

We are using the Microsoft.Owin.Security.Cookies.CookieAuthenticationProvider in an ASP.Net MVC web application. The 'sign in' code uses a custom class that keeps track of authorization info (userRights in the example below). The code looks like this: string auth = JsonConvert.SerializeObject(userRi...
Louis Somers
0

votes
0

answer
15

Views

How to post data to controller from ASP.NET MVC Form and Webgrid

I am new to ASP.NET MVC. I need some help for the following scenario. I have defined a model like this namespace Sample.Models { public class ContModel { [Display(Name = 'Name')] public string Name { get; set; } [Display(Name = 'Code')] public string Code { get; set; } [Display(Name = 'Customer')] p...
Niy
0

votes
0

answer
2

Views

Show Ping Status in list in MVC5

I am Using Asp.net mvc5, I have table with fields like 'id', and 'server_IP' populated with n-numbers of server ip. And wants to display the status of each IP ' success' or 'timeout' depending upon ping. I have used following; Ping myPing = new Ping(); PingReply reply = myPing.Send('8.8.8.8', 1000)...
sahaniarun
1

votes
2

answer
6.9k

Views

asp.net mvc Response.Redirect is not working in global.asax

I am trying to redirect to error page in global.asax file of asp.net mvc5 when any exception occurs in application. After executing Response.Redirect line nothing happening. It is not at all redirecting to errorpage which is available in the path ~\View\Shared\Error.cshtml protected void Application...
Govind
1

votes
1

answer
3.3k

Views

How to upgrade mvc2 to mvc5?

I've got an old project from a friend that he wants me to do redo. How ever that project is written in ASP.net mvc2. So When I try to open it in visual studio 2013 I can errors. Saying the file is incompatible. How would I go ahead and fix this?
Joakim Carlsson
1

votes
1

answer
383

Views

MVC 5 Unit tests vs integration tests

I'm currently working a MVC 5 project using Entity Framework 5 (I may switch to 6 soon). I use database first and MySQL with an existing database (with about 40 tables). This project started as a “proof of concept” and now my company decided to go with the software I'm developing. I am strugglin...
Pierre
1

votes
3

answer
6.3k

Views

Download File C# MVC from byte[]

I am attempting to download a file from a byte array, but the prompt does not appear to do the download. Do I need include additional ContentDisposition attributes? If I look at the network traffic in IE I can see the file request is valid and that it's returning a 200, in addition I can also downlo...
Larry Bargers
0

votes
0

answer
5

Views

Mistake with my code same id but multiple in 2nd table how to get each separate

So I have a user that can create multiple time sheets at a time each if a user creates a timesheet and creates more than 1 project at 1 time it will create separate timesheetdetails for each project but they will all have the same timesheetmaster. How can I specifically pick each timesheetdetail whe...
Bigbear
1

votes
3

answer
83

Views

How do I safely delay a web response in ASP.net?

I have a problem where when we initiate a REST resource from a third party (Twilio), the service responds so quickly, we don't have time to write our SID's to database. We can't tell the service to wait, as it returns the SID only when the service has initiated. The application itself can't hold the...
Scuba Steve
1

votes
2

answer
28

Views

form serialize is empty on MVC 5 ajax

i'm trying to login through a model inc asp net MVC 5, however, i can't seem to get the data from the form using serialize, there are no errors, it just shows nothing inside data @using (Html.BeginForm('Login', 'Account', new { returnUrl = Request.QueryString['ReturnUrl'] }, FormMethod.Post, new...
Jackal
-1

votes
0

answer
19

Views

Form controls appearing very big

I'm working on a project in asp.net mvc5 using .net 4.6.1. Apparently in my view my controls appear very big and i don't know why. Any suggestions? I Already tried a few different designs of code but witouth any good results. @model Firewall.Models.Rules @{ ViewBag.Title = 'Rules'; } @using (Html.B...
Tim Clinckemalie
0

votes
0

answer
2

Views

How to fix this ajax request to stop failing in MVC5

I'm the similar ajax requests to get other database info working. Perhaps its something minor that is causing the issue. Each time I execute this function it fails and throws the alert. It is returning the 13 user records stored in my database, during debugging I can see that these 13 records are al...
Christopher Shiels
1

votes
1

answer
223

Views

Where does ASP.NET Identity store information about external authentication provider?

In my ASP.NET MVC application, I have enabled authentication using Microsoft and Google accounts. They both are working fine. i.e., I am able to login to my application using my hotmail and gmail both accounts. Once logged in (say, using Microsoft account), I am able to see following screen as well...
Nirman
1

votes
0

answer
32

Views

Authorize attribute on a controller inside an area

I have an Area with a few controllers inside it, decorated with the [Authorize] attribute. I also have a few controllers outside the area. To default to the controller inside the area, I have updated my routes, to look like: routes.MapRoute( name: 'Default', url: '{controller}/{action}/{id}', defaul...
Sameer Anand
1

votes
0

answer
39

Views

Unsure how to list all records using MVC [duplicate]

This question already has an answer here: The model item passed into the dictionary is of type 'ViewModels.SiteModel', 1 answer The model item passed into the dictionary is of type .. but this dictionary requires a model item of type 3 answers I am still very new to MVC. I am trying to display al...
DForck42
1

votes
1

answer
49

Views

Cannot append data to <tbody> element by Jquery append() Method

I have an application developed on ASP.NET MVC5. Following is the code of the controller: namespace ACCOUNTS2.Controllers { public class SelectDealController : Controller { private ACCOUNTSEntities db = new ACCOUNTSEntities(); // GET: /SelectDeal/ public ActionResult Index(string option,string sear...
Uzair Raza
1

votes
1

answer
373

Views

Open Rotativa print dialog automatically

I am using Rotativa to generate a PDF of a view with the intention of printing it. I have the following code public ActionResult PrintTicket(string tempTickID) { //var tick = ctx.vw_printTicket.Where(e => e.noTicket == tempTickID).FirstOrDefault(); // return View(tick); var report = new ActionAsPdf(...
unknown techh
1

votes
0

answer
22

Views

Button type button posting data is not saving in DB

i added on message Box and i am posting that data but not adding in my DB. when i am trying to click Confirm button it is not saving in data-base how it will save to data-base can you please help me. enter image description here var leaveManagement= { leaveData: null, showModal: function(data) { lea...
Dinesh
1

votes
1

answer
113

Views

Editing only part of object in view but pass whole obj to ActionListener

I have a form with a submit button that should pass through the item to the actionlistener. I thought it might be similar to the question in @Html.HiddenFor does not work on Lists in ASP.NET MVC but none of the answers seem to work. You can even see my for-loop taken from one of the answers in there...
Corné
1

votes
0

answer
118

Views

How to enable entity framework in a project in visual studio 2013 C# mvc project?

I am trying to enable entity framework in visual studio 2013. My project is a c# mvc project which is newly created. I have installed entity framework using package manager. Now when I am trying to enable the entity framework, I am getting this error PM> Enable-Migrations No context type was found...
jhon
1

votes
0

answer
143

Views

Customising ASP.NET Dynamic Data with ADO.Net Entity Data Model for Ready Only and Audit

I previously followed the below tutorial on Dynamic Data scaffolding with Entity framework: https://www.youtube.com/watch?v=hWatePj2RmE (Part 1 and Part 2) (ASP.net Scaffolding, Dynamic Data with Entity framework) I used this tutorial to implement a table editing solution, that does the following: D...
DIG
1

votes
0

answer
628

Views

System.Data.DataException: An exception occured while initializing the database

Please help me on this. I have written a code for getting the first record from the database using LINQ My Homecontroler [CustomHandleError] public class HomeController : Controller { Domain domain; public HomeController() { domain = new Domain(); } public ActionResult Index() { HomePageViewModel vm...
Reshmy
1

votes
1

answer
329

Views

Accessing CDN bundles on different ASP.Net MVC site

This is a follow-up question to this: ASP.Net MVC 5 - Deploy separate CDN site with bundled JavaScipt and CSS I want to serve up my JavaScript and CSS bundles from a second ASP.Net website, so I have done the following. Main website (ASP.Net MVC website that has not JS or CSS resources) CDN website...
TheMagnificent11
1

votes
0

answer
149

Views

Convert HTML snippet to a powerpoint slide using OpenXML 2.5 SDK

I'd like to convert an HTML table with styling into a PowerPoint slide using the OpenXML 2.5 SDK and .Net 4.6.1/C# . Is this a feasible approach or should I loop over the data table containing the raw data and build the table components manually into the slide?
codeg
1

votes
1

answer
798

Views

ASP.NET MVC - Taking search criteria as input, and displaying the results, in the same View

In a single ASP.NET Razor view, I want to display 10 textboxes (the user will enter various search criteria into these), and then when the user submits the form and the server processes the action, I want to display the results in the same view (let's assume that there can be around a 1,000 rows tha...
md1000
1

votes
1

answer
22

Views

How to assign pk values from the controllerp

ArticleIDX is the primary key. I would like to assign this primary key to Family. However, the primary key does not seem to be assigned a Family value because the create method is executed and incremented. What should I do in this case? [HttpPost] public ActionResult Create(Articles article) { try...
김세림
1

votes
1

answer
93

Views

ASP.NET MVC Forcing Page Redirect After 5 Minutes (Different Pages)

I am building a gallery website that allows visitors to view different photographs. I want to require visitors to register once they spend more than 5 minutes on the website. This includes page redirections. So, I am trying to come up with a way to redirect visitors to my registration page and disal...
HereToLearn
1

votes
1

answer
191

Views

Passing Item ID to JS Function

I am using ASP.NET MVC 5 with Entity Framework. Currently I have table with buttons on side: @Html.ActionLink('Name', 'DisplayAllAdmin', new { sortOrder = ViewBag.NameSortParm }, htmlAttributes: new { @class = 'sortLabel' }) @Html.DisplayNameFor(model => model.Description) @foreach (var item in Mode...
Xardas
1

votes
1

answer
47

Views

How do I add a parameter to the MVC 5 Account Login action?

The login action in the Account controller in MVC takes two parameters: public async Task Login(LoginViewModel model, string returnUrl) { LoginStatus status = new LoginStatus(); if (!ModelState.IsValid) { return View(model); } .... I want to add one. Like... public async Task Login(LoginViewModel...
Robert
1

votes
1

answer
273

Views

Need a solution for the threads deadlock situation in asp.net async controller

Let's say I have a method calling Mongodb database via .net mongo driver (below-mentioned Collection object is part of its Api): public virtual Task GetAllAsync() { return Collection.Find(Filter.Empty).ToListAsync(); } Now I have an async asp.net controller where I want to call this method from. How...
YMC
1

votes
0

answer
599

Views

How to get client certificate on my application mvc?

I'm developing a authentication system with a user certificates based on C# and MVC and I’m having some problems. I use a SSL security with a CA certificate and I want to get back some certificates on a client side. When I run my application on the local side, I get the personal certificate, and...
jld
1

votes
0

answer
221

Views

Collection with GUID id not binding

I have a pretty simple pair of classes: public class Question { [Key] public int QuestionId { get; set; } [Required] [Display(Name ='Question Text')] public string QuestionText { get; set; } public virtual IList Answers { get; set; } } public class Answer : IValidatableObject { [Key] [DatabaseGenera...
Matt Burland
1

votes
1

answer
128

Views

Disabling request validation for HttpContext.Current.Request.Params

Using MVC5 I use [AllowHtml] on specific model properties to allow HTML to be POSTed up to the server. In some places in code I want to access the Request params like so: string wlid = HttpContext.Current.Request.Params['wlid']; But this fails with a HttpRequestValidationException if any HTML is inc...
Mr. Flibble
1

votes
1

answer
39

Views

Combine int and string in a message MVC5 c#

I am getting information from the DB in MVC. when this happens I would like to display a message at the end of the page (or record) to say whether it was successful or unsuccessful and the number of rows found. This is the code that I have currently. However, I cannot add the CountRows (even if I ad...
user2038084
1

votes
1

answer
359

Views

ASP.NET MVC 5, How to get raw JSON/request-body-content when JSON is invalid?

I have the following code to get raw JSON in my action method var stream = new MemoryStream(); var context = (HttpContextBase)request.Properties['MS_HttpContext']; if (context.Request.InputStream != null) {      context.Request.InputStream.Seek(0, SeekOrigin.Begin);      context.Request.Inpu...
fahadash
1

votes
1

answer
224

Views

Check box in Kendo TreeList

How To Use Check Box (Select Row) In Kendo TreeList columns.Add().Template(@).ClientTemplate('').Width(50);
mehdi.mahdavi
1

votes
1

answer
443

Views

Get client IP in Azure through MVC 5 controller

I can't find a question or post specific to Azure for this, and I'm not sure what's different in the environment in Azure versus my testing environments that would cause this. I've tried a few methods to get this to work but I'm not coming right. Please note this isn't Webapi, so using the HttpRequ...
Topher
1

votes
1

answer
58

Views

How to check user roles in View MVC5

As the question says, I am trying to check for a user object's roles in MVC5 View. Basically what my view does is a listing of all the registered users and their current role. Here's my view: @model IEnumerable @{ ViewBag.Title = 'Talent Center Institute: Usuarios'; ViewBag.Menu = 'Usuarios'; ViewB...
l_degaray
1

votes
2

answer
165

Views

How to query data with calculated fields and map to a ViewModel with a nested ViewModel Collection?

I have referenced numerous questions on this site related to calculated fields and ViewModels, but I can't seem to extrapolate from examples given. I hope that laying out a specific scenario would allow someone to pin point what I can't see. I am new to WebApp design in general. Please take that...
Brad Rekkedal
1

votes
0

answer
164

Views

asp.net mvc 5 windows authentication workaround

updated I am working with a project (lets call it project A) which runs on ASP.MVC 5 and uses Windows Authentication in order to proceed with its users. project A has db A behind it. Also there is totally separated project B. It is a console application, which has its database (db B). I need regular...

View additional questions