各种坑还没填完,但是还是走上新的学习之路,性能非常好的.net core http://www.techempower.com/benchmarks/
怎么写出一个页面并给相应的方法呢,我是照葫芦画瓢,在Weather forecast的基础上写了MessageBoard

import React, { Component } from 'react'; export class MessageBoard extends Component { static displayName = MessageBoard.name; constructor(props) { super(props); this.state = { messageboards: [], loading: true }; } componentDidMount() { this.populateWeatherData(); } static renderForecastsTable(messageboards) { return ( <table className='table table-striped'> <thead> <tr> <th>title</th> <th>name</th> <th>message</th> <th>leaveDate</th> </tr> </thead> <tbody> {messageboards.map(messageboard => <tr key={messageboard.name}> <td>{messageboard.title}</td> <td>{messageboard.name}</td> <td>{messageboard.message}</td> <td>{messageboard.leaveDate}</td> </tr> )} </tbody> </table> ); } render() { let contents = this.state.loading ? <p><em>Loading...</em></p> : MessageBoard.renderForecastsTable(this.state.messageboards); return ( <div> <h1>留言板呀</h1> <p>这就是服务器所有的留言</p> {contents} </div> ); } async populateWeatherData() { const response = await fetch('Messageboard'); const data = await response.json(); this.setState({ messageboards: data, loading: false }); } }
并在NavMenu.js加入<NavLink tag={Link} className="text-dark" to="/message-board">Messageboard</NavLink>
还有App.js加入 <Route path='/message-board' component={MessageBoard} /> 当然要先import
react就是这样,接下来就是我们的类和controller

using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using MySql.Data.MySqlClient; // For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 namespace HelloDemo.Controllers { [ApiController] [Route("[controller]")] public class MessageBoardController : ControllerBase { private readonly ILogger<MessageBoardController> _logger; public MessageBoardController(ILogger<MessageBoardController> logger) { _logger = logger; } [HttpGet] public IEnumerable<MessageBoard> Get() { List<MessageBoard> list = new List<MessageBoard>(); //连接数据库 MySqlConnection connection = new MySqlConnection { ConnectionString = "server = bobhuang.xyz; userid = root; password = root; database = messageboards; " }; connection.Open(); //查找数据库里面的表 MySqlCommand mscommand = new MySqlCommand("select * from messages", connection); using (MySqlDataReader reader = mscommand.ExecuteReader()) { //读取数据 while (reader.Read()) { list.Add(new MessageBoard() { Name = reader.GetString("name"), Title = reader.GetString("title"), Message = reader.GetString("message"), LeaveDate = reader.GetDateTime("created_at") }); } } return list.ToArray(); } } }

using System; namespace HelloDemo { public class MessageBoard { public string Name { get; set; } public string Title { get; set; } public string Message { get; set; } public DateTime LeaveDate { get; set; } } }
连接数据库需要导入包
然后还有些厉害的操作
ICollection<T> 同时继承IEnumerable<T>和IEnumerable两个接口
IList 继承它们三个接口,List 是类,不仅实现它们的接口,而且还扩展了很多的方法
按照功能排序:List < IList < ICollection < IEnumerable
按照性能排序:IEnumerable < ICollection < IList < List
using语句
定义一个范围,在范围结束时处理对象。
场景:
当在某个代码段中使用了类的实例,而希望无论因为什么原因,只要离开了这个代码段就自动调用这个类实例的Dispose。
要达到这样的目的,用try...catch来捕捉异常也是可以的,但用using也很方便。
json里英语还用英语,中文用的是u+四位十六进制数
u则代表unicode编码,是一个字符;
0x开头代表十六进制,实际上就是一个整数;
U607C代码汉子烦
Decimal | UTF-8 | UTF-16 | UTF-32 |
---|---|---|---|
24700 | E6 81 BC | 607C | 0000607C |
字符编码笔记:ASCII,Unicode 和 UTF-8 所谓编码--泛谈ASCII、Unicode、UTF8、UTF16、UCS-2等编码格式)
就这样莫名其妙学了一波前端的内容,js使用的是usc-2,utf-16是usc-2的超集,用两位表示比如emoj。存在辅助平面,如果ud800-udbff之间,则需要与后一个字符放在一起,js可以解析,
比如UTF-16:D869 DEA5,UTF-32:0002A6A5
可以直接访问controller获取json数据是否安全?
接下来就是去学习Microsoft Azure,一堆骚操作,keyvault、cosmos db、app service