首页 新闻 会员 周边

一般不是需要提交数据用POST,获取页面用GET吗?

0
[已解决问题] 解决于 2014-09-01 15:02
<style type="text/css">
    #left {width:200px; min-height:500px;border:1px solid #ccc;float:left;}
    #right { width:740px;min-height:500px;border:1px solid #ccc;float:left;margin-left:10px;}
</style>
<div id="left">
    <ul>
        <li>@Ajax.ActionLink("news title a", "Contents",new{id=1}, new AjaxOptions {HttpMethod="Post",InsertionMode= InsertionMode.Replace, UpdateTargetId="news_content" })</li>
        <li>@Ajax.ActionLink("news title b", "Contents",new{id=2}, new AjaxOptions {HttpMethod="Post",InsertionMode= InsertionMode.Replace, UpdateTargetId="news_content" })</li>
    </ul>
</div>
<div id="right">
    <div id="news_content"></div>
</div>



  [HttpPost]
        public ActionResult Contents(int? id)
        {
            IList<string> list1 = new List<string>
            {
                "a news 1 title",
                "a news 2 title",
                "a news 3 title",
                "a news 4 title",
                "a news 5 title"
            };
            IList<string> list2 = new List<string>
            {
                "b news 1 title",
                "b news 2 title",
                "b news 3 title",
                "b news 4 title",
                "b news 5 title",
                "b news 6 title",
                "b news 7 title"
            };
            var model = list1;
            if (id != 1)
            {
                model = list2;
            }
           
            return PartialView(model);
        }


这个只是从后台取数据 为啥不用GET 用POST?
吴顶天的主页 吴顶天 | 初学一级 | 园豆:39
提问于:2014-08-20 11:41
< >
分享
最佳答案
0

用GET在有的浏览器会缓存数据  所以 如果 常常 有变化的 你可以选用post一 反正 也没什么

奖励园豆:5
望着天的蜗牛 | 菜鸟二级 |园豆:354 | 2014-08-20 21:10
其他回答(6)
0

可以用GET

dudu | 园豆:31007 (高人七级) | 2014-08-20 11:46
0

GET和POST方法有区别的,可以根据需要来选择

_crazysnail_ | 园豆:204 (菜鸟二级) | 2014-08-20 12:12
0

获取页面应该用GET, 但有时候使用Ajax 来弹出模态窗口的时候 如果用GET, 就可能导致页面被缓存,每次弹出的内容都一样不会更新。 具体看情况。

丶谦信 | 园豆:308 (菜鸟二级) | 2014-08-20 13:21
0

可以使用GET方法发送数据,但是发送的数据会append在你的URL上面,由于URL是有长度限制的,故一般不用GET方法发送数据,而且从保密性考虑,这样的方式会泄露用户私密信息。

POST发送数据,通过form表单发送,更隐蔽

姜楠 | 园豆:202 (菜鸟二级) | 2014-08-20 20:27
0

不是,都可以。

forhells | 园豆:724 (小虾三级) | 2014-08-21 11:06
0

、、

夏冬更迭 | 园豆:206 (菜鸟二级) | 2015-07-16 12:40
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册