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
Post a Comment