asp.net - Create global function in c# -


completely new c#, please patient me.

i have application 2 links. 1 link see, 1 people see. code , files , exact same, difference if link contains string in it, hides areas of page using jquery.

so, have lot of different cshtml pages , don't want have rewrite logic use check username , redirect or not in each page.

i know how username, check if name in 'special list array' , redirect appropriate website if not... don't know how can efficiently. if 1 person gets added array, have update array on every page.

is there place can put function , call on each cshtml page?

string username = environment.username;  // system.security.principal.windowsidentity.getcurrent().name; string[] arr1 = new string[] { "one", "two", "three" }; bool inarray = false; (int = 0; < arr1.length; i++) {     if (username == arr1[i]){         inarray = true;     } } if(inarray) {     response.redirect("link1"); } else {     response.redirect("link2"); } 


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -