c# - Unexpected token < in JSON using ASP.NET MVC and Angular -


i have error, when i'm trying return index page. data client comes server correctly, i'm trying return index page , getting error. please, check code, wrong?

account.service.ts:

login(url: string, model: any): observable<any> {     let body = json.stringify(model);     let headers = new headers({ 'content-type': 'application/json' });     let options = new requestoptions({ headers: headers });     return this._http.post(url, body, options)         .map((response: response) => <any>response.json())         .catch(this.handleerror); } 

account.component.ts

onsubmit(formdata: any) {              this._accountservice.login(global.base_user_endpoint+"account/login", formdata._value).subscribe(                 data => {                     if (data == 1) {                         this.msg = "success";                     }                     else {                         this.msg = "something wrong while login";                     }                 },                 error => {                     console.log(this.msg);                 }             );  } 

and controller:

public actionresult login(loginviewmodel login)     {         //...         return redirecttoaction("index", "home");     } 

from controller method login, returning statement:

return redirecttoaction("index", "home"); 

which return html view, whereas on client-side, expecting json response "response.json()"

you must return actionresult client-side _accountservice.login method , redirecting action there based on result.


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -