Re: [Cppcms-users] Can't jump to another page from server side
Brought to you by:
artyom-beilis
From: 陈抒 <csf...@gm...> - 2012-01-08 08:38:30
|
Hello,Artyom: Please see my comments below. 陈抒 Best regards http://blog.csdn.net/sheismylife On Sun, Jan 8, 2012 at 3:48 PM, Artyom Beilis <art...@ya...> wrote: > 1. Are you sure you call response().set_redirect_header(...) before you > call response().out()? Because this is likely the reason it may not work. > >> yes. > > 2. Show me the code :-) > My codes looks like so: kaimei_web_site::kaimei_web_site(cppcms::service &srv):cppcms::application(srv){ //web page dispatcher().assign("/welcome" , &kaimei_web_site::welcome , this , 1); //first page dispatcher().assign("/register" , &kaimei_web_site::register_client , this , 2); //register a new account on this page .... //restful web method called by Javascript form client-side dispatcher().assign("/send_email" , &kaimei_web_site::save_email , this , 7); dispatcher().assign("/create_account?(.+)" , &kaimei_web_site::create_account , this , 8); .... } //render the register html page for user void kaimei_web_site::register_client(std::string url){ BOOSTER_INFO("kaimei_web_site") << "enter register_client function"; init_session(); string language = this->session().get("language"); language_cache& cache = app_singleton_holder::Instance().cache(); content::welcome_content content = cache.get(language).clone_welcome_content(); configuration& config = app_singleton_holder::Instance().config(); content.base_uri=config.base_uri; content.jsonp= config.jsonp; render("create_account","create_account_view",content); } void kaimei_web_site::create_account(std::string str){ try{ init_session(); string email = request().post().find("email")->second; string pwd = request().post().find("pwd")->second; user_manager::create_account(email,pwd); string language = this->session().get("language"); shared_ptr<web_user> user = user_manager::login(email,pwd); if(user){ BOOSTER_INFO("kaimei_web_site") << "login succeeded"; this->session()["email"]=user->email; this->session()["user_id"]=user->oid; configuration& config = app_singleton_holder::Instance().config(); response().set_redirect_header(config.jsonp + "/user_home"); //I try to redirect to new page but failed }else{ kaimei::response res; res.message="Login failed!"; res.status=kaimei::response::LOGIN_ERROR; response().out()<<cppcms::json::value(res); } }catch(std::exception &ex){ kaimei::response res; res.message=ex.what(); res.status=kaimei::response::CREATE_ACCOUNT_ERROR; response().out()<<cppcms::json::value(res); } } the real value of config.jsonp (gdb) p config.jsonp $1 = {static npos = <optimized out>, _M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>}, _M_p = 0x80c6e24 "http://localhost:8081/kaimei"}} 3. Small example that reproduces the problem. > >>I can create it if necessary,but need some hours. > 4. What is the web server you are using, what protocol? > (some web servers like nginx, do not handle Status header properly > over SCGI protocol). > > > >> In my development environment,I just use cppcms and HTTP protocol. > Artyom Beilis > -------------- > CppCMS - C++ Web Framework: http://cppcms.sf.net/ > CppDB - C++ SQL Connectivity: http://cppcms.sf.net/sql/cppdb/ > > ------------------------------ > *From:* 陈抒 <csf...@gm...> > *To:* cpp...@li... > *Sent:* Sunday, January 8, 2012 9:30 AM > *Subject:* [Cppcms-users] Can't jump to another page from server side > > Hello, > I tried response().set_redirect_header(...) function ,but it doesn't > work. > If one user registers his/her account into my web site successfully,the > page will jump to user's home page automatically. > > 陈抒 > Best regards > http://blog.csdn.net/sheismylife > > > ------------------------------------------------------------------------------ > Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex > infrastructure or vast IT resources to deliver seamless, secure access to > virtual desktops. With this all-in-one solution, easily deploy virtual > desktops for less than the cost of PCs and save 60% on VDI infrastructure > costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > > > > > ------------------------------------------------------------------------------ > Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex > infrastructure or vast IT resources to deliver seamless, secure access to > virtual desktops. With this all-in-one solution, easily deploy virtual > desktops for less than the cost of PCs and save 60% on VDI infrastructure > costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > > |