基于.NET Core 框架搭建WebApi项目
一 什么是.NET Core?
随着2014年 Xamarin和微软发起.NET基金会,微软在2014年11月份开放.NET框架源代码。在.NET开源基金会的统一规划下诞生了.NET Core 。也就是说.NET Core Framework是参考.NET Framework重新开发的.NET实现,Mono是.NET Framework的一个开源的、跨平台的实现。
二 .NET Core与.NET FrameWork和Mono之间的联系?
.NET Framework将成为.NET Core在Windows上的一个发行版,Mono将成为.NET Core的一个跨平台发行版。
三. 如何构建.NET Core项目?
1.安装环境配置:
首先你电脑上的vs版本是2015 并且保证已经升级至 update3及以上,如果你还没升级,请从此链接下载升级 ed2k://|file|cn_visual_studio_enterprise_2015_with_update_3_x86_x64_dvd_8923298.iso|7787208704|A1C1D2AFBC09D8778C92CF19DEC8F4F4|/
如果你上述操作已经完成,那么你还需要下载.NET Core的SDK和Tools来安装,下载链接https://download.microsoft.com/download/A/3/8/A38489F3-9777-41DD-83F8-2CBDFAB2520C/packages/DotNetCore.1.0.0-SDK.Preview2-x64.exe
https://download.microsoft.com/download/2/F/8/2F864C4E-6980-4AFC-B64E-0AC04837FD6C/DotNetCore.1.0.0-VS2015Tools.Preview2.0.1.exe
提示:如果在安装DotNetCore.1.0.0-VS2015Tools出现以下问题
解决办法如下:
1.关闭当前的VS开发工具,以便继续安装;
2.检查是否出现网络问题,去掉IE浏览器的证书认证
3.如果以上不能帮你解决问题,可以尝试直接进入exe所在的文件夹在运行命令
DotNetCore.1.0.0-VS2015Tools.Preview2.exe SKIP_VSU_CHECK=1
2.创建一个.NET Core web项目
我们来看看与传统的MVC有何不同
可以发现与传统的MVC目录结构并没多大出入,那么尝试写一个Demo吧!
新建一个webapi项目:
可以看到路由自定义部分现已放在了APIController中,默认为api/controller,此处已重写路由
如要创建POST或者GET请求函数,与之前定义一致,在函数上面标记上[HttpPost]或者[HttpGet],模拟请求代码就不一一列举了,请自行脑补。
附上一个HttpClient请求帮助类:
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks; namespace Common
{
/// <summary>
/// HttpClient的帮助类
/// 2015年11月12日14:43:45
/// </summary>
public class HttpClientHelper
{
/*Edit Desc: 提取默认的Http Heads UserAgen Author:Xuja Time:2016-5-3 16:46:29*/
private static readonly string userAgen = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36"; /// <summary>
/// 根据Url地址Get请求返回数据
/// 2015年11月12日14:50:02
/// </summary>
/// <param name="url">请求的地址</param>
/// <param name="ch_httpcode">http状态码</param>
/// <returns>字符串</returns>
public static string GetResponse(string url, out string httpStatusCode)
{
httpStatusCode = string.Empty;
HttpClient httpClient = new HttpClient(new HttpClientHandler() { AutomaticDecompression = DecompressionMethods.GZip });
HttpResponseMessage response = null;
try
{
//httpClient.MaxResponseContentBufferSize = 256000;
httpClient.DefaultRequestHeaders.Add("user-agent", userAgen);
//httpClient = new HttpClient();
//using (HttpClient httpClient = new HttpClient())
//{
httpClient.CancelPendingRequests();
httpClient.DefaultRequestHeaders.Clear();
httpClient.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/json"));
Task<HttpResponseMessage> taskResponse = httpClient.GetAsync(url);
taskResponse.Wait();
response = taskResponse.Result;
//using (HttpResponseMessage response = taskResponse.Result)
//{ //HttpResponseMessage response = httpClient.GetAsync(url).Result;
if (response.IsSuccessStatusCode)
{
Task<System.IO.Stream> taskStream = response.Content.ReadAsStreamAsync();
taskStream.Wait();
//此处会抛出异常:不支持超时设置,对返回结果没有影响
System.IO.Stream dataStream = taskStream.Result;
System.IO.StreamReader reader = new System.IO.StreamReader(dataStream);
string result = reader.ReadToEnd(); return result;
}
//}
return null;
//}
}
catch
{
return null;
}
finally
{
if (response != null)
{
response.Dispose();
}
if (httpClient != null)
{
httpClient.Dispose();
}
}
} /// <summary>
/// 根据Url地址Get请求返回数据
/// xuja
/// 2015年11月12日14:50:02
/// </summary>
/// <param name="url">请求的地址</param>
/// <returns>字符串</returns>
public static string GetResponse(string url)
{
HttpClient httpClient = new HttpClient(new HttpClientHandler() { AutomaticDecompression = DecompressionMethods.GZip });
HttpResponseMessage response = null;
try
{
//httpClient.MaxResponseContentBufferSize = 256000;
httpClient.DefaultRequestHeaders.Add("user-agent", userAgen);
//httpClient = new HttpClient();
//using (HttpClient httpClient = new HttpClient())
//{
httpClient.CancelPendingRequests();
httpClient.DefaultRequestHeaders.Clear();
httpClient.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/json"));
Task<HttpResponseMessage> taskResponse = httpClient.GetAsync(url);
taskResponse.Wait();
response = taskResponse.Result;
//using (HttpResponseMessage response = taskResponse.Result)
//{ //HttpResponseMessage response = httpClient.GetAsync(url).Result;
if (response.IsSuccessStatusCode)
{
Task<System.IO.Stream> taskStream = response.Content.ReadAsStreamAsync();
taskStream.Wait();
System.IO.Stream dataStream = taskStream.Result;
System.IO.StreamReader reader = new System.IO.StreamReader(dataStream);
string result = reader.ReadToEnd(); return result;
}
//}
return null;
//}
}
catch
{
return null;
}
finally
{
if (response != null)
{
response.Dispose();
}
if (httpClient != null)
{
httpClient.Dispose(); }
}
} /// <summary>
/// 根据Url地址Get请求返回实体
/// xuja
/// 2015年11月12日14:50:02
/// </summary>
/// <param name="url">请求的地址</param>
/// <returns>实体</returns>
public static T GetResponse<T>(string url)
{
HttpClient httpClient = new HttpClient(new HttpClientHandler() { AutomaticDecompression = DecompressionMethods.GZip });
HttpResponseMessage response = null;
try
{
//using (HttpClient httpClient = new HttpClient())
//{
//httpClient.MaxResponseContentBufferSize = 256000;
httpClient.DefaultRequestHeaders.Add("user-agent", userAgen);
httpClient.CancelPendingRequests();
httpClient.DefaultRequestHeaders.Clear();
httpClient.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/json"));
//HttpResponseMessage response = httpClient.GetAsync(url).Result;
Task<HttpResponseMessage> taskResponse = httpClient.GetAsync(url);
taskResponse.Wait();
T result = default(T);
response = taskResponse.Result;
//using (HttpResponseMessage response = taskResponse.Result)
//{
if (response.IsSuccessStatusCode)
{
Task<System.IO.Stream> taskStream = response.Content.ReadAsStreamAsync();
taskStream.Wait();
System.IO.Stream dataStream = taskStream.Result;
System.IO.StreamReader reader = new System.IO.StreamReader(dataStream);
string s = reader.ReadToEnd(); result = JsonConvertTool.DeserializeObject<T>(s); }
//}
return result;
//}
}
catch (Exception e)
{
var resp = new HttpResponseMessage(HttpStatusCode.InternalServerError)
{
Content = new StringContent(e.ToString()),
ReasonPhrase = "error"
};
//throw new HttpResponseException(resp);
return default(T);
}
finally
{
if (response != null)
{
response.Dispose();
}
if (httpClient != null)
{
httpClient.Dispose(); } }
} /// <summary>
/// 处理Get的Url
/// des:huyf
/// </summary>
/// <param name="dic"></param>
/// <returns></returns>
public static string WithParameters(Dictionary<string, string> dic)
{
string result = "?";
foreach (var item in dic)
{
result += item.Key + "=" + item.Value + "&";
}
result = result.Remove(result.Length - ); return result;
} /// <summary>
/// Post请求返回字符
/// </summary>
/// <param name="url">请求地址</param>
/// <param name="postData">请求数据</param>
/// <returns>字符</returns>
public static string PostResponse(string url, string postData)
{
HttpClient httpClient = new HttpClient(new HttpClientHandler() { AutomaticDecompression = DecompressionMethods.GZip });
HttpResponseMessage response = null;
try
{
//using (HttpClient httpClient = new HttpClient())
//{
httpClient.MaxResponseContentBufferSize = ;
httpClient.DefaultRequestHeaders.Add("user-agent", userAgen);
httpClient.CancelPendingRequests();
httpClient.DefaultRequestHeaders.Clear();
HttpContent httpContent = new StringContent(postData);
httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
Task<HttpResponseMessage> taskResponse = httpClient.PostAsync(url, httpContent);
taskResponse.Wait();
response = taskResponse.Result;
//using (HttpResponseMessage response = taskResponse.Result)
//{
//HttpResponseMessage response = httpClient.PostAsync(url, httpContent).Result;
if (response.IsSuccessStatusCode)
{
Task<System.IO.Stream> taskStream = response.Content.ReadAsStreamAsync();
taskStream.Wait();
System.IO.Stream dataStream = taskStream.Result;
System.IO.StreamReader reader = new System.IO.StreamReader(dataStream);
string result = reader.ReadToEnd();
return result;
}
//}
return null;
//}
}
catch
{
return null;
}
finally
{
if (response != null)
{
response.Dispose();
}
if (httpClient != null)
{
httpClient.Dispose(); } } }
/// <summary>
/// Post请求返回字符
/// </summary>
/// <param name="url">请求地址</param>
/// <param name="postData">请求数据</param>
/// <returns>字符</returns>
public static string PostResponse(string url, object obj)
{
HttpClient httpClient = new HttpClient(new HttpClientHandler() { AutomaticDecompression = DecompressionMethods.GZip });
HttpResponseMessage response = null;
try
{
//using (HttpClient httpClient = new HttpClient())
//{
httpClient.MaxResponseContentBufferSize = ;
httpClient.DefaultRequestHeaders.Add("user-agent", userAgen);
httpClient.CancelPendingRequests();
httpClient.DefaultRequestHeaders.Clear();
string postData = JsonConvertTool.SerializeObject(obj);
HttpContent httpContent = new StringContent(postData);
httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
Task<HttpResponseMessage> taskResponse = httpClient.PostAsync(url, httpContent);
taskResponse.Wait();
response = taskResponse.Result;
//using (HttpResponseMessage response = taskResponse.Result)
//{
//HttpResponseMessage response = httpClient.PostAsync(url, httpContent).Result;
if (response.IsSuccessStatusCode)
{
Task<System.IO.Stream> taskStream = response.Content.ReadAsStreamAsync();
taskStream.Wait();
System.IO.Stream dataStream = taskStream.Result;
System.IO.StreamReader reader = new System.IO.StreamReader(dataStream);
string result = reader.ReadToEnd();
return result;
}
else
{
//LogHelper.WriteInfo(typeof(HttpClientHelper), "结果:" + response.StatusCode + "内容:" + JsonConvertTool.SerializeObject(obj));
}
//}
return null;
//}
}
catch (Exception exception)
{
//LogHelper.Error("结果:异常 内容:" + JsonConvertTool.SerializeObject(obj) + "ex:" + exception.Message, exception);
return null;
}
finally
{
if (response != null)
{
response.Dispose();
}
if (httpClient != null)
{
httpClient.Dispose(); } } }
/// <summary>
/// Post请求返回实体
/// </summary>
/// <param name="url">请求地址</param>
/// <param name="postData">请求数据</param>
/// <returns>实体</returns>
public static T PostResponse<T>(string url, string postData)
{
HttpClient httpClient = new HttpClient(new HttpClientHandler() { AutomaticDecompression = DecompressionMethods.GZip });
HttpResponseMessage response = null;
try
{
//using (HttpClient httpClient = new HttpClient())
//{
httpClient.MaxResponseContentBufferSize = ;
httpClient.DefaultRequestHeaders.Add("user-agent", userAgen);
httpClient.CancelPendingRequests();
httpClient.DefaultRequestHeaders.Clear();
HttpContent httpContent = new StringContent(postData); httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
T result = default(T);
Task<HttpResponseMessage> taskResponse = httpClient.PostAsync(url, httpContent);
taskResponse.Wait();
response = taskResponse.Result;
//using (HttpResponseMessage response = taskResponse.Result)
//{
//HttpResponseMessage response = httpClient.PostAsync(url, httpContent).Result;
if (response.IsSuccessStatusCode)
{
Task<System.IO.Stream> taskStream = response.Content.ReadAsStreamAsync();
taskStream.Wait();
System.IO.Stream dataStream = taskStream.Result;
System.IO.StreamReader reader = new System.IO.StreamReader(dataStream);
string s = reader.ReadToEnd();
result = JsonConvertTool.DeserializeObject<T>(s);
}
//}
return result;
//}
}
catch
{
return default(T);
}
finally
{
if (response != null)
{
response.Dispose();
}
if (httpClient != null)
{
httpClient.Dispose(); } } } /// <summary>
/// Post请求返回实体
/// </summary>
/// <param name="url">请求地址</param>
/// <param name="postData">请求数据</param>
/// <returns>实体</returns>
public static T PostResponse<T>(string url, object obj)
{
HttpClient httpClient = new HttpClient(new HttpClientHandler() { AutomaticDecompression = DecompressionMethods.GZip });
HttpResponseMessage response = null;
try
{
//using (HttpClient httpClient = new HttpClient())
//{
httpClient.MaxResponseContentBufferSize = ;
httpClient.DefaultRequestHeaders.Add("user-agent", userAgen);
httpClient.CancelPendingRequests();
httpClient.DefaultRequestHeaders.Clear();
string postData = JsonConvertTool.SerializeObject(obj);
HttpContent httpContent = new StringContent(postData); httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
T result = default(T);
Task<HttpResponseMessage> taskResponse = httpClient.PostAsync(url, httpContent);
taskResponse.Wait();
response = taskResponse.Result;
//using (HttpResponseMessage response = taskResponse.Result)
//{
//HttpResponseMessage response = httpClient.PostAsync(url, httpContent).Result;
if (response.IsSuccessStatusCode)
{
Task<System.IO.Stream> taskStream = response.Content.ReadAsStreamAsync();
taskStream.Wait();
System.IO.Stream dataStream = taskStream.Result;
System.IO.StreamReader reader = new System.IO.StreamReader(dataStream);
string s = reader.ReadToEnd(); result = JsonConvertTool.DeserializeObject<T>(s);
}
//}
return result;
//}
}
catch
{
return default(T);
}
finally
{
if (response != null)
{
response.Dispose();
}
if (httpClient != null)
{
httpClient.Dispose(); }
}
} /// <summary>
/// Put请求返回字符
/// </summary>
/// <param name="url">请求地址</param>
/// <param name="postData">请求数据</param>
/// <returns>字符</returns>
public static string PutResponse(string url, object obj)
{
HttpClient httpClient = new HttpClient(new HttpClientHandler() { AutomaticDecompression = DecompressionMethods.GZip });
HttpResponseMessage response = null;
try
{
//using (HttpClient httpClient = new HttpClient())
//{
httpClient.MaxResponseContentBufferSize = ;
httpClient.DefaultRequestHeaders.Add("user-agent", userAgen);
httpClient.CancelPendingRequests();
httpClient.DefaultRequestHeaders.Clear();
string postData = JsonConvertTool.SerializeObject(obj);
HttpContent httpContent = new StringContent(postData);
httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
Task<HttpResponseMessage> taskResponse = httpClient.PostAsync(url, httpContent);
taskResponse.Wait();
response = taskResponse.Result;
//using (HttpResponseMessage response = taskResponse.Result)
//{
//HttpResponseMessage response = httpClient.PutAsync(url, httpContent).Result;
if (response.IsSuccessStatusCode)
{
Task<System.IO.Stream> taskStream = response.Content.ReadAsStreamAsync();
taskStream.Wait();
System.IO.Stream dataStream = taskStream.Result;
System.IO.StreamReader reader = new System.IO.StreamReader(dataStream);
string result = reader.ReadToEnd();
return result;
}
//}
return null;
//}
}
catch
{
return null;
}
finally
{
if (response != null)
{
response.Dispose();
}
if (httpClient != null)
{
httpClient.Dispose(); }
}
} /// <summary>
/// 将Http状态码翻译为对应的中文【暂未使用】
/// </summary>
/// <param name="code">Http状态码</param>
/// <returns>中文解析</returns>
public static string ToChsText(HttpStatusCode code)
{
switch (code)
{
case HttpStatusCode.Continue:
return "请求者应继续进行请求";
case HttpStatusCode.SwitchingProtocols:
return "请求者已要求服务器切换协议,服务器已确认并准备进行切换";
case HttpStatusCode.OK:
return "服务器成功处理了相应请求";
case HttpStatusCode.Created:
return "请求成功且服务器已创建了新的资源";
case HttpStatusCode.Accepted:
return "服务器已接受相应请求,但尚未对其进行处理";
case HttpStatusCode.NonAuthoritativeInformation:
return "服务器已成功处理相应请求,但返回了可能来自另一来源的信息";
case HttpStatusCode.NoContent:
return "服务器已成功处理相应请求,但未返回任何内容";
case HttpStatusCode.ResetContent:
return "服务器已成功处理相应请求,但未返回任何内容,但要求请求者重置文档视图";
case HttpStatusCode.PartialContent:
return "服务器成功处理了部分 GET 请求";
case HttpStatusCode.MultipleChoices:
return "服务器可以根据请求来执行多项操作";
case HttpStatusCode.Moved:
return "请求的网页已永久移动到新位置";
case HttpStatusCode.Redirect:
return "服务器目前正从不同位置的网页响应请求,但请求者应继续使用原有位置来进行以后的请求";
case HttpStatusCode.RedirectMethod:
return "当请求者应对不同的位置进行单独的 GET 请求以检索响应时,服务器会返回此代码";
case HttpStatusCode.NotModified:
return "请求的网页自上次请求后再也没有修改过";
case HttpStatusCode.UseProxy:
return "请求者只能使用代理访问请求的网页";
case HttpStatusCode.Unused:
return "Unused 是未完全指定的 HTTP/1.1 规范的建议扩展";
case HttpStatusCode.RedirectKeepVerb:
return "服务器目前正从不同位置的网页响应请求,但请求者应继续使用原有位置来进行以后的请求";
case HttpStatusCode.BadRequest:
return "服务器未能识别请求";
case HttpStatusCode.Unauthorized:
return "请求要求进行身份验证";
case HttpStatusCode.PaymentRequired:
return "保留 PaymentRequired 以供将来使用";
case HttpStatusCode.Forbidden:
return "服务器拒绝相应请求";
case HttpStatusCode.NotFound:
return "服务器找不到请求的资源";
case HttpStatusCode.MethodNotAllowed:
return "禁用相应请求中所指定的方法";
case HttpStatusCode.NotAcceptable:
return "无法使用相应请求的内容特性来响应请求的网页";
case HttpStatusCode.ProxyAuthenticationRequired:
return "请求者应当使用代理进行授权";
case HttpStatusCode.RequestTimeout:
return "服务器在等待请求时超时";
case HttpStatusCode.Conflict:
return "服务器在完成请求时遇到冲突";
case HttpStatusCode.Gone:
return "请求的资源已被永久删除";
case HttpStatusCode.LengthRequired:
return "服务器不会接受包含无效内容长度标头字段的请求";
case HttpStatusCode.PreconditionFailed:
return "服务器未满足请求者在请求中设置的其中一个前提条件";
case HttpStatusCode.RequestEntityTooLarge:
return "服务器无法处理相应请求,因为请求实体过大,已超出服务器的处理能力";
case HttpStatusCode.RequestUriTooLong:
return "请求的 URI 过长,服务器无法进行处理";
case HttpStatusCode.UnsupportedMediaType:
return "相应请求的格式不受请求页面的支持";
case HttpStatusCode.RequestedRangeNotSatisfiable:
return "如果相应请求是针对网页的无效范围进行的,那么服务器会返回此状态代码";
case HttpStatusCode.ExpectationFailed:
return "服务器未满足“期望”请求标头字段的要求";
case HttpStatusCode.InternalServerError:
return "服务器内部遇到错误,无法完成相应请求";
case HttpStatusCode.NotImplemented:
return "请求的功能在服务器中尚未实现";
case HttpStatusCode.BadGateway:
return "服务器作为网关或代理,从上游服务器收到了无效的响应";
case HttpStatusCode.ServiceUnavailable:
return "目前服务器不可用(由于超载或进行停机维护)";
case HttpStatusCode.GatewayTimeout:
return "服务器作为网关或代理,未及时从上游服务器接收请求";
case HttpStatusCode.HttpVersionNotSupported:
return "服务器不支持相应请求中所用的 HTTP 协议版本";
default:
return "未知Http状态";
}
} } }
MVC控制器中实现代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using apicore.Controllers;
using Common; // For more information on enabling MVC for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860 namespace myfirstcore.Controllers
{
public class FristCoreController : Controller
{
private CoreApiController bll = new CoreApiController();
private string url = "http://localhost:55802/api/coreapi/sayhi"; /// <summary>
/// 我的第一个core项目
/// </summary>
/// <returns></returns>
public IActionResult Index()
{
ViewData["core"] = "第一个core";
return View();
} public IActionResult Api()
{
NumberTo n = new NumberTo();
n.x = ;
n.y = ;
// string result= HttpClientHelper.PostResponse(url,n);
string result = HttpClientHelper.GetResponse(url);
ViewBag.result = result;
return View();
} /// <summary>
/// 页面局部刷新
/// </summary>
/// <returns></returns>
public IActionResult AsyncPage()
{
return View();
}
} /// <summary>
/// 用户实体
/// </summary>
public class NumberTo
{
public int x { get; set; } public int y { get; set; }
}
}
请求成功后的视图页面
提醒:由于webapi不支持跨域请求,遇到跨域问题请在IIS配置api站点,并将此站点添加到host文件即可。
至此,一个基于.NET Core访问WebAPI的项目就完成了。
补充下,由于post请求无法通过url进行调试访问,这里推荐一个可视化API UI 组件Swagger
配置教程请参考:http://www.cnblogs.com/Leo_wl/p/5463839.html
界面展示
基于.NET Core 框架搭建WebApi项目的更多相关文章
- webapi框架搭建-创建项目(二)-以iis为部署环境的配置
上篇:webapi快速框架搭建-创建项目(一) 在"创建项目(一)"这一篇里已经创建了一个空的项目,但项目上什么都没有,本篇描述如何将webapi配置成部署在iis上. 步骤 用n ...
- 一步一步使用ABP框架搭建正式项目系列教程之本地化详解
返回总目录<一步一步使用ABP框架搭建正式项目系列教程> 本篇目录 扯扯本地化 ABP中的本地化 小结 扯扯本地化 本节来说说本地化,也有叫国际化.全球化的,不管怎么个叫法,反正道理都是一 ...
- 基于Gin+Gorm框架搭建MVC模式的Go语言后端系统
文/朱季谦 环境准备:安装Gin与Gorm 本文搭建准备环境:Gin+Gorm+MySql. Gin是Go语言的一套WEB框架,在学习一种陌生语言的陌生框架,最好的方式,就是用我们熟悉的思维去学.作为 ...
- 关于使用ABP框架搭建的项目升级时需要注意的问题汇总
ABP理论学习总目录 一步一步使用ABP框架搭建正式项目系列教程 ABP之Module-Zero学习目录 本篇目录 说明 升级方法 问题_01:Log4Net导致编译不成功 2015/12/18更新 ...
- 如何创建一个基于 .NET Core 3 的 WPF 项目
在 Connect(); 2018 大会上,微软发布了 .NET Core 3 Preview,以及基于 .NET Core 3 的 WPF:同时还发布了 Visual Studio 2019 预览版 ...
- webapi框架搭建-创建项目(三)-webapi owin
上一篇:创建项目(二) 在上一篇里,我们已经创建好了webapi应用,并已经部署到iis里,本篇讲如何用owin自宿主或是iis宿主来部署webapi应用. owin介绍 传统的asp.net网站只能 ...
- webapi框架搭建-webapi异常处理
webapi框架搭建系列博客 前言 上一篇我们已经完成了项目的日志管理,在项目开发中日志会经常记录程序中的异常,供后续问题排查使用.本篇讲如何在webapi里加入异常处理机制. 目的和原则 1.程序任 ...
- 02.基于IDEA+Spring+Maven搭建测试项目--详细过程
一.背景介绍 1.1公司相关技术 Git:是一款免费的开源的分布式版本控制系统,用于敏捷高效地处理任何或小或大的项目,方便多人集成开发 Maven:是基于项目对象模型(POM),可以通过一小段描述信息 ...
- 基于.NET Core的优秀开源项目合集
开源项目非常适合入门,并且可以作为体系结构参考的好资源, GitHub中有几个开源的.NET Core项目,这些项目将帮助您使用不同类型的体系结构和编码模式来深入学习 .NET Core技术, 本文列 ...
随机推荐
- Could not find method google() for arguments [] on repository container.
出这个问题主要是你Gradle版本太低的原因,一般要使用4.0+的版本 所以你需要更新你的Gradle版本至4.0+呦 tips:注意你的AndroidStudio版本应该是3.0以上,因为Gradl ...
- Confluence 6 为一个空间应用一个主题
主题允许你对 Confluence 的外表和显示进行自定义.你的 Confluence 空间管理员可以到 The Atlassian Marketplace 上下载主题. 一旦一个主题被安装到 Con ...
- 【洛谷p1319】压缩技术
(许久不见,甚是想念) 压缩技术[传送门] 洛谷上滴算法标签: 然而这是一道入门难度的题.(不管不管,就写它了) 好的先说一下思路吧wait!我忘记了咋做的当时. 首先做题第一道坎儿,如何输入若干个( ...
- 迷宫最短路径问题的dfs,bfs实现
迷宫的最短路径 给定一个大小为 N×M的迷宫.迷宫由通道和墙壁组成,每一步可以向邻接的上下左右四格的通道移动.请求出从起点到终点所需的小步数.请注意,本题假定从起点一定可以移动到终点 限制条件:N,M ...
- Matlab-5:牛顿迭代法工具箱
function [f,L]=Newton(f,a) %this is newton teration whic is used for solving implicit One-dimensiona ...
- link标签实现给网页标题前加一个小图标favicon.ico
使用方法如下:1.<link rel="shortcut icon " type="images/x-icon" href="./favicon ...
- Spring注解之 @EnableScheduling计划任务注解
要实现计划任务,首先通过在配置类注解@EnableScheduling来开启对计划任务的支持, 然后在要执行计划任务的方法上注解@Scheduled,声明这是一个计划任务 示例:计划任务执行类 在这个 ...
- Eclipse直接打开类文件/文件夹所在的本地目录
1.Eclipse原生的文件浏览操作 选择项目目录/文件 按 ALT+SHIFT +W , 会弹出菜单点击 System Explorer 就可以打开文件所在的本地目录了: 设置工具目录 Run -- ...
- 二、持久层框架(Hibernate)
一.Hibernate对象的状态 实体类对象在Hibernate中有3中状态:瞬时,持久,脱管. 瞬时:没有和Hibernate发生任何关系,在数据库中也没有对应的记录,一旦JVM结束,对象就消失了 ...
- android studio maven 仓库的使用
转自:http://www.cnblogs.com/sihaixuan/p/4852974.html 原文:How to distribute your own Android library thr ...