Click here to Skip to main content
16,023,339 members

Comments by brian5795 (Top 5 by date)

brian5795 18-Oct-23 1:17am View    
Ok i understand that but my question then is in understanding how this works in say production on live server iis, when say two people are accessing the site at the same time this object will contain the last value entered for both people. Like i said i thought the application on the iis server would create a new instance for each person but i guess it doesn't. I am not sure how to deal with that. I always thought when someone accessed a web app from iis that it would be a new instance isolated from others. Now i realize that they are not. I was using static for a different reason and i can probably find another way to do what i want to do, but it just shed some light on the effects on serving a site live. I didnt know it would act that way, as in the data entered into that object by one person is accessable to all. I just thought the 'static' would be available to its own instance of the app by say an individual browser. Any thoughts?
brian5795 17-Oct-23 20:43pm View    
sorry i am new to this forum so i am not sure how to post the code to look better than that. hope you can follow.
brian5795 17-Oct-23 20:41pm View    
Just to clarify, i am not using user data at this point. Just in the most simplistic form, i have one page

orderform.cshtml



















function Update() {

document.getElementById('input-div').style.backgroundColor = 'green';

var firstnamein = document.getElementById('firstname').value;

var fileform = new FormData;

fileform.append("firstnamein", firstnamein);


$.ajax(
{
url: "./orderform?handler=Update",
type: 'POST',
data: fileform,
async: true,
cache: false,
contentType: false,
processData: false,
beforeSend: function (xhr) {
xhr.setRequestHeader("XSRF-TOKEN", $('input:hidden[name="__RequestVerificationToken"]').val());
},

success: function (Return) {


}


});


document.getElementById('input-div').hidden = true;

document.getElementById('confirm-div').hidden = false;


$('#confirm-div').load('./orderview');
}




orderform.cshtml.cs


public class orderformModel : PageModel
{
public static string firstname { get; set; }
public void OnGet()
{
}

public async Task<iactionresult> OnPostUpdateAsync(string firstnamein)
{
firstname = firstnamein;

return Content("OK");
}



}


and then

orderview.cshtml


@page
@{
Layout = "_PlainLayout";
}


Hello @orderformModel.firstname



So with this, if you go to orderform, enter name, and click next, it will bring up the orderview with Hello 'firstname'. when run on the server iis and you go to the page on one computer and put name in and click next it will show the name entered. But you also can go to a different computer then and pull up orderview and it will show the name entered on the other computer. So i believe i am missing some fundamental property of web apps and iis. Like i said i always believed that iis created a new instance of the objects or app so that new connections would not share data. I hope that makes sense.
brian5795 17-Oct-23 7:04am View    
Yes thanks, that is i guess what i am trying to figure out. Like i stated before, i thought that instances of the web app would be created for each computer or browser accessing the app on iis, so that if you pull up the form, and i pull up the form, there are separate instances of the objects created, but it seems i am wrong about that assumption.
brian5795 17-Oct-23 6:39am View    
Yeah sorry not sure i explained it well. I have the session set up as you have stated. The problem is the same whether i use session variable or not so do not really want to focus on the session part of it. Say i have a page orderform.cshtml with an input for firstname, i have a button to submit the name to public static string firstname { get; set; } declared in orderform.cshtml.cs. then using js i load another page orderview.cshtml in div in orderform.cshtml which then displays the name @orderformModel.firstname. If i pull the orderform up on one computer, enter a name and submit, it loads orderview and displays the name i entered. If i then go to a different computer and load the orderview page it also displays then name i entered on the other computer.