IsPost 判断
@{ var world="hello world!"; if(IsPost) { world="posted"; } Response.Write(world); } <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <title></title> </head> <body> @{ for (int i=1;i<10;i++) { <a href="#">@i.ToString()</a> } } <form method="post"> <input type="submit" value="button"/> </form> </body> </html>
IsPost
form method 类型需要设置为 post