开发者

Design question about wcf and page navigation

I have a c#/asp.net 4.0(not MVC) website where a user can search for various items. The search/results functionality works something like this:

On the search page the user fills out the search criteria(textboxes, dropdowns, etc...), and clicks a submit button. The on_click event handler does some validation and/or error checking. If everything checks out, I create an object to hold all the values and place the object into session. I then do a response.redirect to the results page. On the results page I read the object out of session and contact a wcf service and pass the object to it. The wcf does the search and returns the results(if any) and I display the results.

I was curious if there was a better way to do this. It works ok, but something doesn't feel right about it. I'm not too wild about loading the object into session.

I'd prefer to send the object(with the search criteria) to the wcf, then do a redirect, have the results page hold up loading until I get a response back from the wcf service. Once I get the results, back go ahead and load the page with the results.

Is this possible? Any fee开发者_Go百科dback/links would be appreciated.

Also there won't be any third parties using our wcf service, this is all inhouse.


There are three ways how to do that

  • Instead of passing data as post use simple GET to the search page. Search criteria will be passed in URL as done for example by google.
  • Cross page post back - feature available since .NET 2.0. It will remove the session and redirect. You can also use Server.Transfer / Server.Execute.
  • AJAX callback. Your search will not post the form but call the service directly to get the result. You can either use ASP.NET script manager and stuff around that or use some lightweight javascript framework like jQuery. Your WCF service must expose webHttpEndpoint with JSON encoding.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜