小编Moh*_*iri的帖子

清除Asp.net Core中的所有cookie

我正在开发Asp.net Core网站,在我的注销链接中,我想删除所有当前的域名cookie.当我使用Asp.net MVC时,我尝试了这段代码

string[] myCookies = Request.Cookies.AllKeys;
foreach (string cookie in myCookies)
{
  Response.Cookies[cookie].Expires = DateTime.Now.AddDays(-1);
}
Run Code Online (Sandbox Code Playgroud)

此代码在Asp.net Core中不起作用.如何清除Asp.net Core中的所有cookie?

asp.net-core

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

如何在Visual Studio代码中创建WPF项目?

我正在启动Visual Studio代码。我有两个问题:

  1. 如何在Visual Studio代码中创建WPF(Windows Presentation Foundation)项目?
  2. 如何在Visual Studio代码中创建类库(业务层,数据层等)?

c# wpf class-library visual-studio-code

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

检测底部滚动条

我正在做一些表单验证,但我被困在“条款和条件”页面上。我在屏幕底部固定了一个按钮(始终可见)和“条款和条件”文本。如果用户尚未滚动到文本底部,则该按钮将被禁用。但我不知道如何检查是否已到达文本底部......这就是我请求您帮助的原因。

先感谢您

编辑:我尝试了这样的事情(我在 StackOverflow 上找到的):

    @HostListener("window:scroll", ["$event"])
    onWindowScroll() {
      //In chrome and some browser scroll is given to body tag
      let pos = (document.documentElement.scrollTop || document.body.scrollTop) + document.documentElement.offsetHeight;
      let max = document.documentElement.scrollHeight;
      // pos/max will give you the distance between scroll bottom and and bottom of screen in percentage.
      if (pos == max) {
       console.log("done");
    }
  }
Run Code Online (Sandbox Code Playgroud)

还有另一件事,content.directionY但它对我不起作用

ionic3 angular

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

角度致命错误:堆限制附近的无效标记压缩分配失败

我使用过 Angular 5
我尝试ng build --prod
显示这个错误:
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

我已经阅读了这个这个并改变-max_old_space_sizepackage.json但没有构建生产再次显示上述错误。
有什么问题?怎么解决?是package.json的问题吗?

包.json:

{
  "name": "asd",
  "version": "0.6.2",
  "license": "MIT",
  "angular-cli": {},
  "scripts": {
    "build:dev": "./node_modules/.bin/ng build",
    "build:prod": "./node_modules/.bin/ng build --prod --aot=false",
    "build:aot": "./node_modules/.bin/ng build --prod --aot",
    "build:aot2": "node --max_old_space_size=4096 ./node_modules/.bin/ng build --prod --aot",
    "build": "npm run build:dev",
    "clean:dist": "npm run rimraf -- dist",
    "clean:install": "npm set progress=false && …
Run Code Online (Sandbox Code Playgroud)

angular

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

访问被拒绝的文件在asp.net核心


当我将项目发布到iis并且确实在浏览器中上传图片时,此操作失败并在logger sysytem

发生未处理的异常:拒绝访问路径'C:\ Inetpub \ vhosts \ qarbal.com \ back.qarbal.com \ wwwroot \ images \ UserProfile \pic_50.jpg'。System.UnauthorizedAccessException:访问路径' C:\ Inetpub \ vhosts \ qarbal.com \ back.qarbal.com \ wwwroot \ images \ UserProfile \ pic_50.jpg'被拒绝。在System.IO.FileStream..ctor处位于System.IO.FileStream.OpenHandle(FileMode模式,FileShare共享,FileOptions选项)(字符串路径,FileMode模式,FileAccess访问,FileShare共享,Int32 bufferSize,FileOptions选项)

动作控制器

[HttpPost("[action]")]
public async Task<IActionResult> EditPhoto()
{
    var uploadsRootFolder = Path.Combine(_env.WebRootPath, "images\\UserProfile");
    var files = Request.Form.Files;     
    foreach (var file in files)
    {       
        if (file == null || file.Length == 0)
        {
            continue;
        }
        var filePath = Path.Combine(uploadsRootFolder, queryModel.Name  + files[0].FileName);
        using (var fileStream …
Run Code Online (Sandbox Code Playgroud)

c# iis asp.net-core

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

获取Angular 5中的IP地址

我想从http://freegeoip.net/json/?callback 获取Angular 5中的客户端IP地址
我有一个服务

@Injectable()
export class JobService {
constructor(    
    private http: HttpClient) { }
    getIpAddress() {
            const headers = new HttpHeaders({ 'Content-Type': 'application/json' });
            return this.http
              .get('http://freegeoip.net/json/?callback',
              { headers: headers })
              .map(response => response || {})
              .catch(this.handleError);
          }

      private handleError(error: HttpErrorResponse): Observable<any> {
         console.error('observable error: ', error);
         return Observable.throw(error);
      }
}
Run Code Online (Sandbox Code Playgroud)

并在jobcomponent中调用服务

export class JobsDetailComponent implements OnInit {
constructor(
    private jobService: JobService){}


ngOnInit(): void {
    console.log("ip");
    this.jobService.getIpAddress().subscribe(data => {
      console.log(data);
    });

}
Run Code Online (Sandbox Code Playgroud)

当我调用此服务但它没有按预期工作并在浏览器控制台中显示错误.

无法加载http://freegeoip.net/json/?callback:对预检请求的响应未通过访问控制检查:请求的资源上没有"Access-Control-Allow-Origin"标头.因此不允许来源' http:// localhost:4200 …

ajax cross-domain angular

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

TypeScript用于初始数据可以使用接口类型或类类型哪种方法更好?

在TypeScript中获取初始数据可以使用接口类型或类类型
哪种方法更好?

export interface Item{
    text: string,
    value: number
}

itemModel: ItemComboBox = {
    value:'value1',
    text: 'text1'
  };
Run Code Online (Sandbox Code Playgroud)

类:

export class Item{
  constructor(
     public text: string,
     public value: string) { }
}
itemModel= new Item("text1", "value1"); 
Run Code Online (Sandbox Code Playgroud)

typescript angular

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

在In Asp.net Core 2.2.1中访问XMLHttpRequest

在我的Asp.net核心项目中,我使用Microsoft.AspNetCore.App Version =“ 2.2.1”并在启动服务中调用AddCors
Startup.cs

public void ConfigureServices(IServiceCollection services)
{
 services.AddCors(options =>
    {
        options.AddPolicy("CorsPolicy",
            builder => builder
                .AllowAnyOrigin()
                .AllowAnyMethod()
                .AllowAnyHeader()
                .AllowCredentials()
                );
    });

    .....

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            app.UseCors(policyName: "CorsPolicy");  

            .... 
Run Code Online (Sandbox Code Playgroud)

Controller

 [Route("api/[controller]")]
    [EnableCors("CorsPolicy")]
    public class ManageUsersController : Controller
    { ...
Run Code Online (Sandbox Code Playgroud)

在angular 5 App中,当调用Web API时,在浏览器的控制台中显示此错误

CORS策略已阻止从原点' http:// localhost:4200 ' 访问' http:// localhost:5000 / api / Account / LoginByPortal ' 上的XMLHttpRequest :对预检请求的响应未通过访问控制检查:当请求的凭据模式为“ include”时,响应中“ Access-Control-Allow-Origin”标头的值不得为通配符“ *”。XMLHttpRequest发起的请求的凭据模式由withCredentials属性控制。

角度服务:

loginByPortal(credentials: Credentials): Observable<userLoginViewmodel> {
    const headers = new HttpHeaders({ 'Content-Type': …
Run Code Online (Sandbox Code Playgroud)

asp.net-core angular

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