我还在学习网络API,所以请原谅我,如果我的问题听起来很愚蠢.
我有这个StudentController:
public HttpResponseMessage PostStudent([FromBody]Models.Student student)
{
if (DBManager.createStudent(student) != null)
return Request.CreateResponse(HttpStatusCode.Created, student);
else
return Request.CreateResponse(HttpStatusCode.BadRequest, student);
}
Run Code Online (Sandbox Code Playgroud)
为了测试这是否有效,我使用Google Chrome的扩展程序"Postman"来构建HTTP POST请求以对其进行测试.
这是我的原始POST请求:
POST /api/Student HTTP/1.1
Host: localhost:1118
Content-Type: application/json
Cache-Control: no-cache
{"student": [{"name":"John Doe", "age":18, "country":"United States of America"}]}
Run Code Online (Sandbox Code Playgroud)
"student"应该是一个对象,但是当我调试应用程序时,API接收学生对象,但内容始终是NULL.
我一直在使用Bootstrap开发我的网站,基本上,我有这个结构..
<div class="container">
<img src="~/Content/Theme/img/image.png" class="img-responsive" style="margin: 0 auto;" />
</div>
Run Code Online (Sandbox Code Playgroud)
它在Chrome和Firefox上完美运行,但是当我在Internet Explorer 9上测试时,图像会变得更大,甚至超出图像大小本身.当我在IE(F12)上使用调试模式并取消下面的width:100%;设置时.img-responsive,它会恢复正常.
我该如何解决这个问题?我已经在这里尝试了一些解决方案,包括添加.col-sm-12到图像,但它仍然没有在IE上修复它.
html css internet-explorer responsive-design twitter-bootstrap
这是我为ASP.NET Web应用程序使用的当前设计模式,我见过人们使用存储库,但我没有得到存储库设计模式的实现.
任何人都可以指出我如何在我的设计中实现存储库模式?如果我在MY CASE中实现存储库,我将获得什么样的好处.
还有,我应该在设计中实现哪些接口的好用?
客户类(Customer.cs)
public class Customer
{
public int CustomerID { get; set; }
public string Name { get; set; }
public string Address1 { get; set; }
public string Address2 { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
DBManager类(DBManager.cs)
public class DBManager
{
private const string connectionString = "some connection string";
public static IEnumerable<Customer> getAllCustomers()
{
List<Customer> cust = new List<Customer>();
try
{
using (SqlConnection conn = new SqlConnection(connectionString))
{
conn.Open();
string cmdText = "SELECT * FROM Customer"; …Run Code Online (Sandbox Code Playgroud)