我使用.net framework 4.5安装了使用mvc4的visual studio 2012.现在我想使用带有属性编写的webapi2,我希望我的hlep页面能够正确显示所有端点.
在我的解决方案中,我添加了一个新的mvc4基础emtpy项目并使用nuget i升级到mvc5,然后我安装了webapi2软件包.最后我已经为webapi2安装了帮助包.
现在,当我使用routeprefix时,我无法在帮助页面上看到任何内容,当我尝试在浏览器中访问我的webapi端点时,它会抛出以下错误.
<Error>
<Message>
No HTTP resource was found that matches the request URI 'http://expressiis.com/api/v1/'.
</Message>
<MessageDetail>
No type was found that matches the controller named 'v1'.
</MessageDetail>
</Error>
namespace WebApi.Controllers
{
[RoutePrefix("api/v1")]
public class SubscribersController : ApiController
{
// GET api/<controller>
[Route("")]
[HttpGet]
public IQueryable<string> Get()
{
return new string[] { "value1", "value2" }.AsQueryable();
}
}
}
Run Code Online (Sandbox Code Playgroud) 我是角度js的新手,目前仍然坚持使用非常有线的bug.控制器中的函数在通过路径加载的视图调用时运行两次.
你会看到警报两次!!
我的观点很简单
我的应用程序代码如下
var IB = angular.module('IB', []);
//channel controller
IB.controller('channelsController', function ($scope, $routeParams) {
$scope.greet = function () {
alert('hi');
};
});
IB.config(function ($routeProvider) {
$routeProvider
.when('/channels', {
controller: 'channelsController',
template: '{{greet()}}'
})
.otherwise({ redirectTo: '/channels' });
});
Run Code Online (Sandbox Code Playgroud) 我通过以下连接完美地在本地运行点快速启动项目.但是我没有创建mdf文件的位置.
<add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-mirror-quickstart-dotnet-20130523105156;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-mirror-quickstart-dotnet-20130523105156.mdf" />
Run Code Online (Sandbox Code Playgroud)
我已经检查了app_data为空.
无论如何,当我单击谷歌授权页面上显示的接受按钮时,我立即将该项目上传到远程服务器上,它会引发异常.
[Win32Exception (0x80004005): The system cannot find the file specified]
[SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 52 - Unable to locate a Local Database Runtime installation. Verify that SQL Server …Run Code Online (Sandbox Code Playgroud) 我是mongodb的新手,正在为一个新项目开发mvc4 Web应用程序。
我想使用存储库模式,该模式将与mongodb上下文进行数据库级通信。
下面是我与Entity Framework 4.0一起使用的简单界面。寻找成员对我来说是有问题的领域。我不知道如何在mongodb上下文中继续使用它们。
public interface IRepository<T> where T : class
{
void Add(T entity);
void Remove(T entity);
IQueryable<T> Find(Expression<Func<T, bool>> predicate);
//IQueryable<T> FindAll();
}
Run Code Online (Sandbox Code Playgroud)
我有一个非常简单的模型,称为Hero,它来自ImongoEntity的驱动器,该驱动器提供了一个称为accessId的成员。
public class Hero : MongoDB.Kennedy.IMongoEntity
{
public ObjectId _id { get; set; }
public string Name { get; set; }
public string Alias { get; set; }
public string _accessId { get; set;}
}
Run Code Online (Sandbox Code Playgroud)
上下文类非常简单,您可以看到将Heros集合发布为IQueryable属性。
public class MongoDataConetext: MongoDB.Kennedy.ConcurrentDataContext
{
public MongoDataConetext(string databaseName, string serverName="localhost") : base(databaseName, serverName)
{
}
public IQueryable<Hero> …Run Code Online (Sandbox Code Playgroud) 我正在使用EF代码和mvc脚手架开发mvc3.0应用程序.我目前坚持实体之间的多对多关系.我有以下模型.
命名空间BigApp.Models {
#region POCO Objects
public class Group
{
public int Id { get; set; }
public string Name { get; set; }
public DateTime CreatedOn { get; set; }
public DateTime UpdatedOn { get; set; }
public virtual ICollection<Project> Projects { get; set; }
}
public class Project
{
public int Id { get; set; }
public string Name { get; set; }
public string Url { get; set; }
public DateTime CreatedOn { get; set; }
public …Run Code Online (Sandbox Code Playgroud)