首页 新闻 会员 周边

反射获取前台提交的数据,只能获取post,不能获取get形式传过来的数据?

0
悬赏园豆:10 [待解决问题]

我用反射获取前台提交的数据,post过来的数据可以获取,但是get过来的querystring数据不能获取:

这是在??.asp下,可以直接使用Request:

            category model = new category();
            model = baseOpen.GetFormToM<category>(model, Request);
       public static T GetFormToM<T>(T m, HttpRequest context)
        {
            Type t = m.GetType();
            PropertyInfo[] pi = t.GetProperties();
            foreach (PropertyInfo p in pi)
            {
                if (context[p.Name] != null)
                {
                    p.SetValue(m, Convert.ChangeType(context[p.Name], p.PropertyType), null);
                }
            }
            return m;
        }

大哥们可以看下问题吗

少时不知贵的主页 少时不知贵 | 初学一级 | 园豆:86
提问于:2016-08-24 09:32
< >
分享
所有回答(3)
0

以下配置是我做webservice时候的配置,你可以试试。希望对你有帮助!

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="ConnectString" value="Data Source=***;Initial Catalog=***;User ID=sa;pwd=123456"/>
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5.1" />
<httpRuntime targetFramework="4.5.1" />

<webServices>
<protocols>
<add name="HttpPost"/>
<add name="HttpGet"/>
<add name="HttpSoap"/>
<add name="Documentation"/>
</protocols>
</webServices>

</system.web>
</configuration>

chengeng | 园豆:294 (菜鸟二级) | 2016-08-24 09:41
0

1、这是.asp?

2、Request.QueryString[key]

幻天芒 | 园豆:37175 (高人七级) | 2016-08-24 14:19
0

你还是用Request[key]来取吧,这样get,post都能拿到,但唯一不好的是当get和post有相同的key的时候value是中间以逗号隔开连在一起的。

Daniel Cai | 园豆:10424 (专家六级) | 2016-08-24 15:30
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册