Questions tagged [asp.net-mvc-4]

15311 questions
0

votes
1

answer
26

Views

How to call an implemented interface method with different return types? [duplicate]

This question already has an answer here: Does C# support return type covariance? 9 answers I've an interface that has one method with an Interface return type. Is there a way to implement that method in different classes with different return types (derived from the interface return type)? This is...
Phoenix_uy
1

votes
2

answer
37

Views

Need to split a string and count occurrence

I have a string in my ViewData. I need to split it be COMMA and count the occurrence of words. i.e. ViewData['words'] = 'apple,orange,grape'. I need to split and get the answer as 3.
Ranjith Kumar K
1

votes
2

answer
22

Views

How to re-select items in listbox?

I have a web page that has two listbox. I am having a problem with my jQuery/JavaScript. When the user selects an item in the left listbox, it should select three items in the right listbox. It only works the first time unless I refresh the page. I know the code is being executed because I can s...
PKonstant
1

votes
2

answer
179

Views

Does submit button passes its value to action method, on form submit?

Update: What are the control/fields whose value would be submitted when the form is post back? In an ASP.NET MVC Form, if user double clicks on the submit button, the form would be submitted two times. In order to solve this problem I implemented the solution explained here. This is my solution, wh...
Hooman Bahreini
1

votes
2

answer
3.1k

Views

How to return an error if UserName Password does not match in MVC 4?

i am new to MVC, i want to create a simple Login Control. I have write the below code in controller: public ActionResult LoginControl(String UserName, String Password) { string result = ''; if (UserName == 'ram' && Password == 'ram123') { result = '1'; } if (result == '1') { return View('LoginContro...
Ram
1

votes
1

answer
2.6k

Views

Multiple Html.dropdownlistfor with the same selectlist, set selected value

I have a Add/Edit View with several dropdownlistfor, all is populated from the same selectlist. When i try to populate the view for editinng all dropdownlist have the same selected as the first one. Is there a way around this? I don't wanna use multiple selectlist because they all have the same cont...
TobiasW
0

votes
2

answer
25

Views

Need to pass text box values as parameters when calling controller method on button click

I'm working on an MVC form that's supposed to let the user enter some descriptions of their problem in various fields, and the text in those fields will then be compiled into an email and sent to us after the user clicks the 'Submit' button. I've got enough wired up to pass hardcoded strings as par...
R. D.
1

votes
4

answer
540

Views

TimeEntry Js function not working for Dynamically added textboxes

' + '' + '' + I am adding this textboxes on button click. On Document.ready i have written: $(document).ready(function () { $('.driveTimedaySlot').timeEntry({ show24Hours: true, showSeconds: true, defaultTime: '00:00:00' }); }); But it is not firing for dynamically added textboxes
Sagar K
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
954

Views

Umbraco Surface Controller Not Routing Correctly

I have a bit of trouble getting a surface controller to fire correctly. public class SocialShareSurfaceController : Umbraco.Web.Mvc.SurfaceController { public ActionResult Index() { return Content('hello world'); } } I'm trying to get to the controller via this URL: http://website.local/umbraco/surf...
Ayo Adesina
1

votes
1

answer
1.1k

Views

EF Select MAX value that is <= 5

I can not figure out how using EF to select a DB row, based on its maximum value but wich is lower or equals 5. Here is my code, but this will select only a value, and not entire row: Prices pr = db.Prices.Where(s => s.numdays s.numdays) Thank you for your time!
CodeDemen
1

votes
0

answer
698

Views

ASP.NET MVC Razor Sections and Partials

I'm relatively new to ASP.NET MVC and Razor. We've been modifying and developing based on existing code. Thus, there is a lot of duplication (ugh!). So I started looking at Partial pages and learning about Sections. I followed these tutorials but I'm still a bit confused. ASP.NET MVC 3: Layouts...
Patricia
1

votes
0

answer
93

Views

Form Submit Not Work in MVC 5 Project

My Submit Form Button Not Working .. When I press on Login Button Nothing Happens ... I had set breakpoint in my code and Login Post Action not Called after Submit Button Click . I can fix my problem with JQuery ajax codes but I don't want use JQuery Ajax for submitting Form ..I want to understand...
Alireza Askari
1

votes
1

answer
119

Views

GridMvc not filtering all Fields

I'm using GridMvc with asp.net mvc 4.5. All of the filters are working except a few strings. I can't see any difference between these strings and the strings that are working. What am I missing? View @model Infotech.Coverpools.Portal.Tintaglia.Web.Models.AccountHistoryVM @using GridMvc.Html Account...
Josh McGee
1

votes
0

answer
157

Views

Can not install the System.Net.Http Nuget package on a project that supports Multi-Target framework

We were developing a .net application in .Net Framework 4 version. Then we decided to convert the application to multi-platform(net 40, net 45, net46, net47) We converted the application to multi-target platform and began to install nuget packages. We noticed that the System.Net.Http package was not...
sabandurna
1

votes
0

answer
24

Views

Kendo Grid Binding with Razor

I setup a function used to save the grid's state along with its options to a database whenever something is modified. Every user will have their own respective settings. The saving and loading functions of the grip options are functional, however upon page loading, the loadGridState function is cal...
glowstarraw
1

votes
1

answer
73

Views

Why am I not getting the AJAX data in an ASP.Net MVC controller?

I have this code on my page: polyData = [1.2, 1.3, 1.4]; document.getElementById('sentDiv').innerHTML = JSON.stringify(polyData); $.post('/Home/updateData', $.param({ data: JSON.stringify(polyData) }, true), function(data) { $('#dataDiv').html('this is data: ' + JSON.stringify(data)); }); This is i...
mans
1

votes
1

answer
27

Views

How to use attribute routing in for get method with same parameter in web api 2

following is code for calling web API call public async System.Threading.Tasks.Task RequisitionNameByQuantityThisDraw() { //Guid applicationRequisitionOid string userName = string.Empty; SessionObject sessionData = new SessionObject().GetSessionData(); if (sessionData == null) { return RedirectToAct...
1

votes
1

answer
90

Views

ASP.Net MVC migration: access field you're deleting

During a code-first migration, is there any way to access a field that is guaranteed to still exist in the database but may not exist in your model anymore? Context: I am trying to switch from a one-to-many-relation (a one-way reference) to a many-to-many-relation (a mapping table). Of course I woul...
Zeust the Unoobian
1

votes
1

answer
163

Views

How display Details in .cshtml page

How can i display details in .cshtml page while I implementing my DLL File Controller public ActionResult GetEmpById(int Id) { var x = ObjEmpRepo.GetEmployeesById(Id); return View(x); } View @model Business_Dll.Model.Employee_Model @foreach (var empDetail in Model) { } Here Business_Dll is My Dl...
1

votes
1

answer
377

Views

@Url.RouteUrl is empty in ASP.Net MVC 5

I have the following Action on a Controller in ASP.Net MVC 5: [Route('Sprache/{languageName}/Kurs/{courseName}/Text/{value}/Test/{referenzID}', Name = 'Textauswahl')] public ActionResult SelectedText(string languageName, string courseName, string value, string referenzID) { return View('Show...
Darem
1

votes
2

answer
389

Views

MVC route is not using default action

In my web api, I have created this controller: public class DistributionGroupController : ApiController { [HttpGet] public ServiceResult Index(string id) { if (id == null) return null; else return new ServiceResult(); } } In addition, this is my route config. I am specifying my default action for my...
Matt Spinks
1

votes
1

answer
36

Views

Changes on published Globalization.en.resx not longer recognized

in my web project in Visual Studio (VS) 2013 there are 2 Globalization files for language support: Globalization.resx for German and Globalization.en.resx for English. The last year while publishing to the Server everythings works fine. For the last 2 days only the changes to the Globalization.en.re...
dan
1

votes
0

answer
421

Views

google font api not working asp.net mvc bundleconfig

I'm currently working on an ASP.NET MVC application and I'm trying to include a google font into my bundleconfig.cs. Unfortunately it does not work as expected. I'm getting this error: The URL 'https://fonts.googleapis.com/css?family=Rokkitt:200,300,400,700' is not valid. Only application relative U...
john.1020
1

votes
0

answer
31

Views

Error after change namespaces

I am newbie in ASP.NET and I have an issue that I can't solve. I know, I know... there is a lot of information to research about this problem, so I was following all the options and threads, and I can't fix the problem :( Basically I changed the name of my project and the namespaces. I setted the na...
MadDev
1

votes
1

answer
207

Views

Login from one web application and access another web application with same cookie value MVC

I have 3 MVC Web applications: 1 for Managing user Logins and other 2 are separate applications for different tasks. If a user logined in application 1 he can able to access the 2 other applications with the same credential. I am using standard MVC authentication here. It works in localhost, but not...
Aravind C S
1

votes
0

answer
117

Views

Update Browser Title When Open Crystal Report in PDF Format

I am developing a web application using MVC 4. For reporting I am using Crystal Report. My client wants all reports in PDF format and reports should open in a new tab of browser. But after I generate the report in a new tab the tab title is the controller name. I want to set the report name as the b...
Ahmed All Razi
1

votes
0

answer
78

Views

FileSystemWatcher within .NET MVC Deployed Issue

The code below sits in the Global.asx file within my ASP.NET MVC 5 project. It runs perfectly and detects the file changes when debugging and running through the IDE but when published to an IIS server nothing runs. Any ideas on how to get this started? I assumed as its in the application start that...
user2806570
1

votes
1

answer
315

Views

Run PSEXEC process in ASP.NET as different user

I'm trying to connect from my ASP web application published on IIS server to some servers using psExec, start application and get the output. When I try to start process without setting credentials I get this error: Access is denied but if I do the same as administrator, I'm only getting empty fiel...
Toxa O'Connor
1

votes
0

answer
73

Views

MVC Calling Action Method Twice on FileContentResult in IE

I am trying to return a PDF byte array to the client browser inline so it displays right in Internet Explorer. When this code is ran: [HttpGet] public async Task DisplayPDF() { var testImageBytes = Convert.FromBase64String('This is filled in with a base 64 string that is a image'); var pdf = _IPDF....
mameesh
1

votes
1

answer
41

Views

Angular js : How i can change the color of accordion active on click

How can I change the color of an active accordion when I click on the glyphicon using ng-if. I have this code: I can't succeeded to do that have you an idea please. Thanks an advance. style.css: selectionAccordion { &:hover, &:focus { color: White; background-color:Blue; } } .directive('accordion',...
sani
1

votes
0

answer
340

Views

Bootstrap Responsive Layout Asp.Net MVC don't work

I am new to bootstrap with asp.net Mvc. How to create a responsive layout as the below image? My layout moves when I collapse the side menu. And the page is not responsive at all? Do I need to give mediaqueries for all partial views that I render in the _layout.cshtml? Home LayoutAlteredWhenMenuColl...
devvab
1

votes
1

answer
95

Views

Upload image file size is more than actual file size

I am uploading an image in c# using a fileapi plugin. My actual file size is 60kb but after uploading the file size appears as 350kb on the server. Why is this happening? Here is my code for saving an image: public JsonResult SaveImageFile(byte[] file) { var filesData = Request.Files[0]; string file...
Ammar Muhi ud din
1

votes
0

answer
119

Views

MVC| .Net| Excel export not responding when opened in MS Excel

Genterate an excel file from a view, is working fine if file has less data content but when the size gets bigger the file is not responding in MS-Exce. when i tried to open it, a message gets poped up showing: file is croupted or unsafe and if I click yes to open, it fails to respond after taking t...
Rajesh Sharma
1

votes
0

answer
72

Views

ASP.NET MVC. Tuple model - DropdownFor always set null to Action

Values of all fields set to Action correctly except selected value of Gender dropdown list. [HttpGet] public ActionResult AddUser(int roleId) { ..... List genderList = new List { new Gender {Name = 'Male', Value = 'M'}, new Gender {Name = 'Female', Value = 'F'} }; ViewBag.Genders = genderList; r...
ewqewqewqe
1

votes
0

answer
35

Views

How to make an OAuth Authentication from IP

I have a .NET Web Api. I want to consume from webs and Mobile Apps, but I don't want the user to sing in or create an acount. Can I make an authentication from IP or domain name or something similar? I tried to implement a Basic and Oauth Authentication, but don't want to place the plain text with t...
Dani Hernandez
1

votes
0

answer
26

Views

Session variable being lost in different browsers

I'm using a session variable to store an id, which I'm in turn using to represent a shopping basket. I'm setting the value using the following code: HttpContext.Session['MyId'] = Guid.NewGuid().ToString(); This is set at the end of an Action method and then I redirect to another Action, where I then...
Adrian
1

votes
0

answer
32

Views

Update Using Entity Framework is not reflecting my DB table

I'm new to Entity Framework, and wrote a function to update a particular column TStatus. Here is what I'm trying to execute: public ActionResult UpdateTStatus(int ICCID) { using (var db = new MyDBContext()) { var result = db.INTERVIEW_AGENT_CALL_CENTERS.Where(g => g.Id == ICCID).FirstOrDefault();...
Developer
1

votes
1

answer
133

Views

How do I execute code upon session timeout?

I'd like to clear up some temporary data when a user's Session expires on my website. While most data is stored in the session object itself, there are some external locks and reservations I'd like to release alongside the session. Where do I put the code to do this?
Extragorey
1

votes
0

answer
177

Views

1and1 windows hosting, web.config permissions

I'm trying to publish my ASP.NET 4.6 MVC website project to 1and1, but keep receiving this error page. https://i.stack.imgur.com/njzRx.png If this link doesn't work, here's the error details: 'HTTP Error 500.19 - Internal Server Error' Module - IIS Web Core Notification - Unknown Handler - Not yet d...
FullStackIntern98

View additional questions