asp.net-mvc

Preventing cookie replay / cookie use by more than one client

℡╲_俬逩灬. 提交于 2021-02-10 06:08:54
问题 What is the "best practice" to prevent a valid cookie from being used by more than one client at a time in ASP.NET MVC? In this scenario, we are using all the OWASP tricks. Strict HSTS: HTTPS/SSL on every page Cookies are listed as HTTPS-only Cookies are marked secure Cookies have a short expiration There is also code to prevent cross-site request forgery (XSRF) from altering values page to page. That's all great and prevents users from changing values, but it doesn't prevent a bad actor from

Preventing cookie replay / cookie use by more than one client

我的未来我决定 提交于 2021-02-10 06:04:24
问题 What is the "best practice" to prevent a valid cookie from being used by more than one client at a time in ASP.NET MVC? In this scenario, we are using all the OWASP tricks. Strict HSTS: HTTPS/SSL on every page Cookies are listed as HTTPS-only Cookies are marked secure Cookies have a short expiration There is also code to prevent cross-site request forgery (XSRF) from altering values page to page. That's all great and prevents users from changing values, but it doesn't prevent a bad actor from

How can I click on a table cell and display a modal with notes

断了今生、忘了曾经 提交于 2021-02-10 05:56:25
问题 I am fairly to programmming, and have been blocked on an issue for a few days now. I have a table with 2 columns, Record# and notes for each record. The "notes" are usually very long so I was planning on having a link on each cell on the "notes" column with a link to a modal where the notes where displayed. Problem I am facing is that all the links will show the notes for the first item of the table... Here is my code (the td "Notes" is just there for verification purposes): <table> <tbody>

Asp MVC Dropdown List Selected Value not selected

一笑奈何 提交于 2021-02-10 05:49:08
问题 I have the following dropdown list but the selected value doesn't seem to working. It defaults to first item in list. private List<string> GetTransmissions() { List<string> Transmission = new List<string>(); Transmission.Add("Automatic"); Transmission.Add("Manual"); return Transmission; } Car car = _repository.GetCarDetails(id); ViewBag.Transmission = new SelectList(GetTransmissions(), car.Transmission); In my view I have: @Html.DropDownList("Transmission", (IEnumerable<SelectListItem>

Asp MVC Dropdown List Selected Value not selected

℡╲_俬逩灬. 提交于 2021-02-10 05:48:11
问题 I have the following dropdown list but the selected value doesn't seem to working. It defaults to first item in list. private List<string> GetTransmissions() { List<string> Transmission = new List<string>(); Transmission.Add("Automatic"); Transmission.Add("Manual"); return Transmission; } Car car = _repository.GetCarDetails(id); ViewBag.Transmission = new SelectList(GetTransmissions(), car.Transmission); In my view I have: @Html.DropDownList("Transmission", (IEnumerable<SelectListItem>

Asp MVC Dropdown List Selected Value not selected

本秂侑毒 提交于 2021-02-10 05:48:07
问题 I have the following dropdown list but the selected value doesn't seem to working. It defaults to first item in list. private List<string> GetTransmissions() { List<string> Transmission = new List<string>(); Transmission.Add("Automatic"); Transmission.Add("Manual"); return Transmission; } Car car = _repository.GetCarDetails(id); ViewBag.Transmission = new SelectList(GetTransmissions(), car.Transmission); In my view I have: @Html.DropDownList("Transmission", (IEnumerable<SelectListItem>

How to call a server-side function from javascript in MVC?

泪湿孤枕 提交于 2021-02-10 05:45:53
问题 I am doing amendments in my MVC application in order to disallow users to open more than one tab/ window within a single session. I am taking reference of this article (click here) in order to do that. This article is written for asp.net whereas I need to implement this feature for ASP.NET MVC. I think all this should be possible in MVC, however, I am not sure what should I do to re-write this if(window.name != "<%=GetWindowName()%>") GetWindowName() is a function I have created in my

RegularExpression validation fails at ModelState.IsValid when input is 0.00

放肆的年华 提交于 2021-02-10 05:14:59
问题 I have a problem similar to this question I'm using MVC . I have added a regular expression in my ViewModel to force the users to enter a number with 1 or 2 decimal places. I am thinking there must be an error in my Regex but the same statement is working fine elsewhere. If I put in 0.00 as my rate , when I submit my form, ModelState.IsValid returns as false . [RegularExpression(@"^(\d+\.\d{1,2})$", ErrorMessage = "Please enter valid rate with 1 or 2 decimal places")] public double

HttpClient - PostAsJsonAsync

倾然丶 夕夏残阳落幕 提交于 2021-02-10 05:13:15
问题 I'm experiencing a simple yet annoying issue when using the PostAsJsonAsync<T>(..) extension method and I can't find information on fixing the following issue anywhere. My issue is that the Json that gets generated uses PascaCasing and I require camelCasing as per the actual standard. Here's a simple sample that can reproduce the issue (source: http://www.codeproject.com/Articles/611176/Calling-ASP-NET-WebAPI-using-HttpClient): HttpClient client = new HttpClient(); client.BaseAddress = new

dropdown menu populate another c# mvc json ajax

佐手、 提交于 2021-02-10 05:12:32
问题 Below is my code, I am not sure what i am doing wrong? Ajax json jquery code function FillCity() { var countryid = $("select[name$='.countryid']").val(); //<---- this is dynamic $.ajax({ url: "Controller/FillMyCity", type: "POST", dataType: "json", data: { country: countryid } , success: function (city) { $("select[name$='.cityid']").html(""); // <--- this is dynamic $.each(city, function (i, pp) { $("select[name$='.cityid']").append( $('<option></option>').val(pp.cityid).html(pp.name)); });