小编hyp*_*erN的帖子

为不同的TFS团队项目添加解决方案

我不小心将我的解决方案添加到TFS上错误的团队项目中,我已经进入文件/源代码控制/高级/更改源代码控制,我已经选择了所有项目并解除了绑定,转到解决方案,然后右键单击我已选择Add Solution To Source Control,但弹出窗口显示:

    The item 'ProjectName.sln' is already under source control at the selected location. 
    If you are trying to rebind a project that you have already added to source control 
outside Microsoft Visual Studio, you should use the Change Source Control command. If you are 
adding this project for the first time, you should either choose a different server folder for the project or move the 
existing project to a different server folder.
Run Code Online (Sandbox Code Playgroud)

我试图将项目绑定到新的Team项目,但是当我尝试检入时,并未检查整个项目,但只是添加了更改,因为我不小心将其添加到了错误的Team项目中.

总结一下,现在我如何将我的项目添加到TFS源代码管理?

tfs visual-studio-2013

4
推荐指数
1
解决办法
4146
查看次数

C#正则表达式

我有纯文本文件(.txt),它有一些表达式,我想用......替换无效的表达式...让我们说零.

无效表达式是包含1+3^4^5or 10+3+4*5+2^5^6^7的表达式,即表达式不能包含number^number^number^...,它只能包含number^number.

我知道最好的方法是使用正则表达式,但我不知道如何在正则表达式中写这个.

c# regex

3
推荐指数
1
解决办法
447
查看次数

ASP.net Identity从javascript发送AntiForgeryToken

使用ASP.net MVC 5来自帐户控制器和帐户视图.在Register视图中有行

@Html.AntiForgeryToken()
Run Code Online (Sandbox Code Playgroud)

以上寄存器控制器有属性:

[ValidateAntiForgeryToken]
Run Code Online (Sandbox Code Playgroud)

我决定使用JSON从javascript发送数据到服务器(我使用的是Angular和$ http.post方法).

我的问题是如何使用javascript发送此AntiForgeryToken并在控制器中验证它?

我应该包括更多安全措施吗?

javascript asp.net asp.net-mvc angularjs asp.net-identity

3
推荐指数
1
解决办法
1492
查看次数

ConnectionString属性尚未在update-database上初始化

在包管理器控制台中,我在azure上对我的数据库运行命令更新数据库,但是我收到错误,说ConnectionString属性尚未初始化.

我对本地数据库做了同样的事情,一切都很好.在我的web配置中,我已经将连接字符串更改为mach我的azure数据库,这是我的数据库上下文的样子:

 public class MadLabsDatabaseContext : IdentityDbContext<User>
{
    public MadLabsDatabaseContext()
        : base("DefaultConnection")
    {
        Configuration.LazyLoadingEnabled = true;
    }

    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        base.OnModelCreating(modelBuilder);

        modelBuilder.Entity<IdentityUser>()
           .ToTable("AspNetUsers");
        modelBuilder.Entity<User>()
            .ToTable("AspNetUsers");
    }
}
Run Code Online (Sandbox Code Playgroud)

这是web.config中的连接字符串:

<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=tcp:serverName.database.windows.net,1433;Database=madLabs_db;User ID=username;Password=password;Trusted_Connection=False;Encrypt=True;Connection Timeout=30;MultipleActiveResultSets=True;" providerName="System.Data.SqlClient" />
</connectionStrings>
Run Code Online (Sandbox Code Playgroud)

这是我的Package Manager控制台代码:

Update-database -ConnectionString "Data Source=tcp:serverName.database.windows.net,1433;Database=madLabs_db;User ID=userName;Password=password;Trusted_Connection=False;Encrypt=True;Connection Timeout=30;MultipleActiveResultSets=True;" -ConnectionProviderName "System.Data.SqlClient"
Run Code Online (Sandbox Code Playgroud)

为什么我收到此错误?

c# asp.net-mvc azure asp.net-web-api

3
推荐指数
1
解决办法
2631
查看次数

CORS使用asp.net web api 2 odata和breeze

我在使用Breeze消耗我的OData时遇到了问题.我的api托管在另一台服务器上,我使用的是asp.net web api 2.0(随VS 2013预览一起提供).我知道web api已正确配置为CORS,因为我已经测试了它没有微风,它工作正常.

这是支持CORS的web api 2.0代码:

var cors = new EnableCorsAttribute("http://localhost:7122/", "*", "*");
config.EnableCors(cors);
Run Code Online (Sandbox Code Playgroud)

这是我的IEdmModel

private static IEdmModel CreateModel()
{
    var modelBuilder = new ODataConventionModelBuilder {Namespace = "Test.Domain.Model"};
    modelBuilder.EntitySet<MuscleGroup>("MuscleGroup");
    modelBuilder.EntitySet<Exercise>("Exercises");
    modelBuilder.EntitySet<ExerciseCategory>("ExerciseCategories");
    modelBuilder.EntitySet<Muscle>("Muscle");

    return modelBuilder.GetEdmModel();
}
Run Code Online (Sandbox Code Playgroud)

这是控制器:

[EnableCors(origins: "http://localhost:7122", headers: "*", methods: "*")] //this enables CORS for controller 
public class MuscleGroupController : EntitySetController<MuscleGroup, int>
{
    private readonly DatabaseContext _databaseContext = new DatabaseContext();

    [Queryable]
    public override IQueryable<MuscleGroup> Get()
    {
        return _databaseContext.MuscleGroups;
    }

    protected override MuscleGroup GetEntityByKey(int key)
    {
        return …
Run Code Online (Sandbox Code Playgroud)

c# odata cors asp.net-web-api breeze

2
推荐指数
1
解决办法
3386
查看次数

ASP.net Web Api版本控制

我有ASP.net Web Api项目,因此我决定该支持版本了。我正在使用官方的Microsoft Nuget支持版本控制(更多信息在此处),我决定按名称空间进行版本控制(如此处所示)。

不幸的是我无法使代码正常工作。如果我这样调用我的方法:

http://localhost:7291/api/Saved/GetNumberOfSavedWorkoutsForUser?api-version=2.0
Run Code Online (Sandbox Code Playgroud)

我得到错误:

Multiple types were found that match the controller named 'Saved'. This can happen if the route that services this request ('api/{controller}/{action}/{id}') found multiple controllers defined with the same name but differing namespaces, which is not supported.
Run Code Online (Sandbox Code Playgroud)

如果我这样称呼它: http://localhost:7291/v2/Saved/GetNumberOfSavedWorkoutsForUser

我收到错误404:

The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
Run Code Online (Sandbox Code Playgroud)

我不确定自己在做什么错。这是我的代码:

启动文件

public void Configuration(IAppBuilder app)
    {
        var configuration = new HttpConfiguration();
        var …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc asp.net-web-api api-versioning

2
推荐指数
1
解决办法
8076
查看次数

ASP.Net Web Api序列化异常

在Web Api项目中,当我输入url localhost:[portnumber]/api/os时,我得到包含错误的长XML文件,这里是异常消息:

预计不会键入"System.Data.Entity.DynamicProxies.CollegeCourse_C7F37B1980970AF17607E96F17DFE50E3A680141BF8228EEA7D39A9150498388"数据合同名称"//schemas.datacontract.org/2004/07/System.Data.Entity.DynamicProxies CollegeCourse_C7F37B1980970AF17607E96F17DFE50E3A680141BF8228EEA7D39A9150498388:HTTP".考虑使用DataContractResolver或将任何静态未知的类型添加到已知类型列表中 - 例如,通过使用KnownTypeAttribute属性或将它们添加到传递给DataContractSerializer的已知类型列表中.

但是当我输入url localhost:[portnumber]/api/role一切都很好,这里是代码:

OS:

public class UserOS
{
    [Key]
    [HiddenInput(DisplayValue = false)]
    public int UserOSId { get; set; }

    public Guid UserId { get; set; }

    public string OSType { get; set; }

    [ForeignKey("UserId")]
    public virtual User User { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

角色:

public class UserRole
{
    [Key]
    [HiddenInput(DisplayValue = false)]
    public int RoleId { get; set; }

    public string Name { get; set; }

    public ICollection<User> Users { get; …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc entity-framework asp.net-web-api

1
推荐指数
1
解决办法
1044
查看次数

Angular-UI select2动态更改选项中的标签属性

Angular-ui select2标签的官方示例是:

myAppModule.controller('MyController', function($scope) {
    $scope.list_of_string = ['tag1', 'tag2']
    $scope.select2Options = {
        'multiple': true,
        'simple_tags': true,
        'tags': ['tag1', 'tag2', 'tag3', 'tag4']  // Can be empty list.
    };
});
Run Code Online (Sandbox Code Playgroud)

我有这段代码:

$scope.select2Options = {
                        'multiple': true,
                        'simple_tags': true,
                        'tags': $scope.categoryNames
                    };

$scope.$watch(function () { return adminCrudService.getCategoriesForUpdate(); }, function () {
                $scope.action = "edit";
                $scope.categoriesForUpdate = adminCrudService.getCategoriesForUpdate();
                if ($scope.categoriesForUpdate.length > null) {
                    $scope.categoryNames = [];
                    _.forEach($scope.categoriesForUpdate, function (item) {
                        $scope.categoryNames.push(item._backingStore.Name);
                    });

                }
            });
Run Code Online (Sandbox Code Playgroud)

但这只是不起作用,当我点击Selcet2时,我得到没有找到匹配,我在$ watch中记录$ scope.categoryNames,数据就在那里(所以这部分工作正常).

所以我的问题是可以动态加载标签,如果可以,怎么样?

javascript angularjs jquery-select2 angular-ui

1
推荐指数
1
解决办法
2645
查看次数

带输入的角度ng重复

我有这样的观点:

<table class="table">
   <tr data-ng-repeat="exercise in exercises x">
      <td>
           <input type="number" data-ng-model="?????????" />
       </td>
        <td>
           {{exercise.Name}}
        </td>
     </tr>
  </table>
Run Code Online (Sandbox Code Playgroud)

我想知道我应该放什么,data-ng-model所以我可以在我的控制器中使用双向数据绑定,即输入的值?

我试过 data-ng-model="{{exercise.Name}}"但是导致了错误.

另外,如何在控制器中引用某些输入?我可以这样做:$scope.InputOne = ...

javascript angularjs

1
推荐指数
1
解决办法
1165
查看次数

ASP.net web api 2错误"参数字典包含参数的空条目"

我有像这样配置的路由:

   routes.MapHttpRoute("DefaultApi2", "api/{controller}/{action}/{id}", new {id = RouteParameter.Optional}
Run Code Online (Sandbox Code Playgroud)

我的控制器看起来像这样:

  public class RoutineController : ApiController
{
    private readonly RoutineService _routineService;

    public RoutineController(RoutineService routineService)
    {
        _routineService = routineService;
    }



    [HttpGet]
    [ActionName("Tags")]
    public List<RoutineTag> Tags()
    {
        return _routineService.GetAllTags();
    }

    [HttpGet]
    [ActionName("SingleRoutine")]
    // GET api/routine/5
    public RoutineViewModel SingleRoutine(int id)
    {
        return _routineService.GetRoutineById(id);

    }
}
Run Code Online (Sandbox Code Playgroud)

但是我收到了这个错误:

{"Message":"The request is invalid.","MessageDetail":"The parameters dictionary contains a null entry for parameter 'id' of non-nullable type 'System.Int32' for method 'Infrastructure.Api.Models.RoutineViewModel Routine(Int32)' in 'Infrastructure.Api.Controllers.RoutineController'. An optional parameter must be a reference …
Run Code Online (Sandbox Code Playgroud)

c# asp.net asp.net-web-api asp.net-web-api2

1
推荐指数
1
解决办法
8413
查看次数

Azure云服务磁盘上没有足够的空间

我一直在收到错误: Exception Details: System.IO.IOException: There is not enough space on the disk.

我知道这种情况正在发生,因为当用户访问我的页面时,他/她的zip文件被下载然后解压缩.每个zip大约45 MB,解压缩大约50 MB.我在几次访问页面后开始收到此错误(我相信下载1 GB时)并在本地保存到Cloud Service光盘

我在Azure上运行此作为Cloud Service,服务的大小为中:

本地资源= 489 GB Apps =约.1.5 GB

有什么办法可以增加光盘的大小,所以我可以节省50 GB吗?

编辑

以下是我收到错误的代码的一部分:

using (var client = new WebClient())
        {
            client.DownloadFile(link, HostingEnvironment.MapPath("~/ebookDownloads/" + name));


            using (ZipFile zip = ZipFile.Read(HostingEnvironment.MapPath("~/ebookDownloads/" + name)))
            {
                foreach (var e in zip)
                {
                    e.Extract(folderToCreate, ExtractExistingFileAction.OverwriteSilently); // overwrite == false
                    // var filePath = HttpContext.Server.MapPath("~/ebookDownloads/" + nameOfFolder + "/" + e.FileName);
                    var filePath = Path.Combine(Server.MapPath("~/ebookDownloads/" + nameOfFolder), e.FileName);
                    listOfLinks.Add(new EbooksHelper …
Run Code Online (Sandbox Code Playgroud)

azure azure-cloud-services

1
推荐指数
1
解决办法
1637
查看次数

asp.net web api odataNo IdLink

我正在使用带有web api的Odata并收到此错误:

 <m:innererror>
<m:message>
The 'ObjectContent`1' type failed to serialize the response body for content type       'application/json; charset=utf-8'.
</m:message>
<m:type>System.InvalidOperationException</m:type>
 <m:stacktrace/>
<m:internalexception>
 <m:message>
No IdLink factory was found. Try calling HasIdLink on the EntitySetConfiguration for    'Tag'.
</m:message>
 <m:type>System.InvalidOperationException</m:type>
Run Code Online (Sandbox Code Playgroud)

这是我的OData配置:

  config.Routes.MapODataRoute("ODataRoute", "odata", CreateModel());
   static IEdmModel CreateModel()
    {
        var modelBuilder = new ODataModelBuilder();

        modelBuilder.EntitySet<Tag>("Tag");
        modelBuilder.EntitySet<Post>("Post");

        return modelBuilder.GetEdmModel();
    }
Run Code Online (Sandbox Code Playgroud)

这是我的OData控制器

  public class TagController : EntitySetController<Tag, int>
{
    private readonly IUnitOfWork _unitOfWork;

    public TagController(IUnitOfWork unitOfWork)
    {
        _unitOfWork = unitOfWork;
    }


    public override IQueryable<Tag> Get() …
Run Code Online (Sandbox Code Playgroud)

odata asp.net-web-api asp.net-web-api-odata

0
推荐指数
1
解决办法
748
查看次数

Angularjs $ http.get不起作用

在我的服务器端(ASP.ne MVC)我有这样的方法:

    [HttpGet]
    public JsonResult GetTrenings(string treningId)
    {
        var tempId = Guid.Parse(treningId);
        var trening = TreningService.GetTreningById(tempId);
        _trenings = TreningService.GetAllTreningsForUser(trening.UserId);
        return Json(_trenings, JsonRequestBehavior.AllowGet);

    }
Run Code Online (Sandbox Code Playgroud)

我有Angular服务:

publicApp.angularModule.factory('feedSingleTreningService', function ($q, $http) {

return {
   getTrenings: function (data) {
       var input = $http.get("/Feed/GetTrenings", { params: { treningId: data } });


        var deferred = $q.defer();

        deferred.resolve(input);
        return deferred.promise;
    },

};
});
Run Code Online (Sandbox Code Playgroud)

在我的控制器中,我将此服务称为:

 feedSingleTreningService.getTrenings(data).then(function(results) {
        console.log("test", results);
    });
Run Code Online (Sandbox Code Playgroud)

但是在控制台中没有显示任何内容,我调试了服务器端并请求到达它,它返回_trenings,服务也返回promise,但没有任何反应.

我终于改变了,在控制台"test"中显示但结果未定义.

为什么会这样?

javascript asp.net-mvc http-get angularjs

0
推荐指数
1
解决办法
4760
查看次数