小编ibn*_*mza的帖子

在Asp.net mvc5中使用用户名而不是电子邮件来识别身份

每当我使用visual studio 2013 express为web创建一个新应用程序并使用个人帐户身份验证并点击注册按钮时,我注意到它实现了"电子邮件"而不是"用户名",并且在LoginViewModel中也是如此,因为它使用Email来登录而不是用户名.如何将此更改为使用用户名而不是默认电子邮件?另外我想知道如何将字符串类型的默认'guid'转换为'id'(整数类型).

asp.net asp.net-mvc visual-studio

34
推荐指数
2
解决办法
3万
查看次数

使用PagedList.Mvc时出错

我试图使用pagedList.mvc包来查询我从查询得到的结果,我在我的控制器中这样做.

 public ActionResult AllPosts()
    {
       int pageSize = 4;
       int pageNum = (page ?? 1);
       var query = from p in db.Posts
select new ListPostsVM()
                    {
                        PostTitle = p.PostTitle,
                        Author = p.UserProfile.UserName,
                        DateCreated = p.DateCreated,
                        CategoryName = p.Category.CategoryName
                    };
return View(query.ToPagedList(pageNum, pageSize));
    }
Run Code Online (Sandbox Code Playgroud)

在我看来,我做到了这一点

@model IPagedList<Blogger.ViewModels.ListPostsVM>
@using PagedList;
@using PagedList.Mvc;
@{
    ViewBag.Title = "AllPosts";
    Layout = "~/Views/Shared/_AdminLayout.cshtml";
}
<link href="~/Content/PagedList.css" rel="stylesheet" />
<h2>AllPosts</h2>
<div class="allposts">
    <table class="table">
        <tr>
            <th>Title</th>
            <th>Author</th>
            <th>Category</th>
            <th>Date</th>
        </tr>
        @foreach (var item in Model)
        {
            <tr> …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc

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

将 Java RSA 非对称加密转换为 Flutter Dart

我正在尝试将我们的 Android 移动应用程序移植到 Flutter。它是用 Java 编写的。然而,在这一部分中,我需要在发布到服务器之前使用 RSA 加密来加密登录凭据和卡详细信息,但我无法做到这一点。

\n\n

我已经尝试了几个 flutter 包,但不起作用。根据Java开发人员的说法,有一个base64编码的公钥需要用于加密密码。

\n\n

这是Java代码

\n\n
public  static  String Encrypt(String plaintext, String publicKey ) throws Exception {\n  try\n  {\n\n      if(StringUtils.isEmpty(plaintext)) return "";\n      byte[] modulusBytes = Base64.decode(publicKey.getBytes("UTF-8"),Base64.DEFAULT);\n      byte[] exponentBytes = Base64.decode("AQAB".getBytes("UTF-8"),Base64.DEFAULT);\n      BigInteger modulus = new BigInteger(1, modulusBytes );\n      BigInteger exponent = new BigInteger(1, exponentBytes);\n      RSAPublicKeySpec rsaPubKey = new RSAPublicKeySpec(modulus, exponent);\n      KeyFactory fact = KeyFactory.getInstance("RSA");\n      PublicKey pubKey = fact.generatePublic(rsaPubKey);\n\n      Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1PADDING");\n      cipher.init(Cipher.ENCRYPT_MODE, pubKey);\n\n      byte[] plainBytes = new String(plaintext).getBytes("UTF-8");\n      byte[] cipherData = …
Run Code Online (Sandbox Code Playgroud)

java encryption dart flutter

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

Flutter 中的每个数据流或每个 ViewModel 流 - 推荐哪个?

我在我的 Flutter 应用程序中使用 BLoC 模式进行状态管理,并且我已经使用这两种方法来管理状态数据。e

1. making each piece of data have its own stream and using StreamBuilder for each widget that needs the data in the UI 

    class LoginBloc{
      bool _isLoggedIn;
      String _username;
      String _password;


      final _isloggedInSubject = BehaviorSubject<bool>();
      StreamSink<bool> get isLoggedInSink => _isloggedInSubject.sink;

      final _usernameSubject = BehaviorSubject<String>();
      StreamSink<String> get userNameSink => _usernameSubject.sink;
      //... //same for the other states

      bool login(){
        _service.Login(_usernameSubject.value,...);
      }
    }

2. Wrapping all page state in a view model and then making just one stream …
Run Code Online (Sandbox Code Playgroud)

dart flutter bloc

5
推荐指数
0
解决办法
398
查看次数

为什么即使存在于数据库中,角色也显示为"不存在"(asp.net mvc)

我正在尝试在注册用户时将用户添加到角色中,因此我将角色播种并使用以下代码在migrations.cs类中更新数据库

        var RoleManager = new RoleManager<IdentityRole>(new RoleStore<IdentityRole>(context));
        string[] roleNames = { "Admin", "Reviewer", "User" };
        IdentityResult roleResult;
        foreach (var roleName in roleNames)
        {
            if (!RoleManager.RoleExists(roleName))
            {
                roleResult = RoleManager.Create(new IdentityRole(roleName));
            }
        }
Run Code Online (Sandbox Code Playgroud)

我试图将roleNames提取到我的accountcontroller类的下拉列表中

public ActionResult Register()
{
    var model = new RegisterViewModel();
        model.RolesList = new SelectList(_db.Roles, "Id", "Name");

    return View(model);
}

//
// POST: /Account/Register
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public async Task<ActionResult> Register(RegisterViewModel model)
{
    if (ModelState.IsValid)
    {
        var user = new ApplicationUser()
        {
            UserName = model.UserName,
            PortalUser = new PortalUser() …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc asp.net-identity

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

Http.Get()总是在角度2中返回undefined

按照教程,教师正在使用spotify api构建spotify音乐搜索.按照教练所做的每一步,但问题是我的数据永远不会回来,我得到了未定义,没有任何东西出现在屏幕上.但是,如果我直接在浏览器中点击api,则会显示json数据,但不会在我的应用中显示.

其实我已经看过很多像这样的问题,但没有一个能解决我的问题.我认为它可能是一个与网络相关的问题,但是当我设置断点时,我可以在响应中看到结果,但是没有任何东西被加载到视图中,未定义被加载到控制台中

**search.component.html**
<h1>Need Music?</h1>
<p class="lead">
  Use the ngSpotify app to browse new releases of your favorite songs. See what your favorite artistes are up to.
</p>
<form>
  <div class="form-group">
    <input type="text" name="searchStr" [(ngModel)]="searchStr" (keyup.enter)="searchMusic()" class="form-control" placeholder="Search music here..."/>
  </div>
</form>

**search.component.ts**
import { Component, OnInit } from '@angular/core';
import { SpotifyService } from '../../Services/spotify.service';  
@Component({
  selector: 'app-search',
  templateUrl: './search.component.html',
  styleUrls: ['./search.component.css']
})
export class SearchComponent implements OnInit {

  constructor(private _spotifyservice: SpotifyService) { }

  searchStr: string;
  searchResult;

  searchMusic() …
Run Code Online (Sandbox Code Playgroud)

angular-http angular2-services angular2-observables angular

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

在 asp.net mvc 中创建多级评论系统

我目前正在编写一个用 asp.net mvc 编写的博客。我有一个表,其中存储具有以下模型的评论

public partial class Comment
    {
        public int CommentId { get; set; }
        public string Comment { get; set; }
        public System.DateTime CommentDate { get; set; }
        public int AuthorId { get; set; }
        public int PostId { get; set; }
        public int CategoryId { get; set; }

        public virtual Category Category { get; set; }
        public virtual Post Post { get; set; }
        public virtual UserProfile UserProfile { get; set; }
    } 
Run Code Online (Sandbox Code Playgroud)

目前评论仍为一级评论,即用户无法回复评论。我如何实现多级评论系统,以便评论可以有回复,而该回复可以有另一个回复等等。

c# asp.net-mvc

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