10
1
using System;
2
using System.ComponentModel.DataAnnotations;
3
4
namespace HelloWorldMvcApp
5
{
6
public class SampleViewModel
7
{
8
9
}
10
}
49
1
@model HelloWorldMvcApp.SampleViewModel
2
@{
3
Layout = null;
4
}
5
6
<!DOCTYPE html>
7
<!-- template from http://getbootstrap.com/getting-started -->
8
9
<html lang="en">
10
<head>
11
<meta charset="utf-8">
12
<meta http-equiv="X-UA-Compatible" content="IE=edge">
13
<meta name="viewport" content="width=device-width, initial-scale=1">
14
<!-- CSS Includes -->
15
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
16
</head>
17
18
<body>
19
<div class="container">
20
<br/>
21
<input type="button" value="Get Results" onclick="getResults()" class="btn btn-primary"/>
22
<br/>
23
<div class="form-group">
24
<label for="usr">Response:</label>
26
1
using System;
2
using System.Web.Mvc;
3
using System.Collections.Generic;
4
using System.Threading.Tasks;
5
using Newtonsoft.Json.Linq;
6
7
namespace HelloWorldMvcApp
8
{
9
public class HomeController : Controller
10
{
11
[HttpPost]
12
public async Task<JObject> GetResults(string token)
13
{
14
JObject json = JObject.Parse("{myDate:1,token:\""+token+"\"}");
15
return json;
16
}
17
18
[HttpGet]
19
public ActionResult Index()
20
{
21
return View(new SampleViewModel());
22
}
23
24
}
25
26
}