小编s.k*_*aul的帖子

类型或命名空间名称"Mvc"不存在

我最近安装了visual studio 2013.从网上下载了一个示例项目后,我运行它时,它给了我以下错误 -

The type or namespace name 'Mvc' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)  
Run Code Online (Sandbox Code Playgroud)

如何克服这个错误?

asp.net-mvc visual-studio-2013

48
推荐指数
2
解决办法
7万
查看次数

在asp.net mvc 4中调用jquery ajax之后的服务器端重定向

我将jQuery AJAX调用的登录信息发送到MVC 4控制器:

   $.post(url, data, function (response) {
      if (response=='InvalidLogin') {
          //show invalid login
      }
      else if (response == 'Error') {
          //show error
      }
      else {
          //redirecting to main page from here for the time being.
          window.location.replace("http://localhost:1378/Dashboard/Index");
      }
   });
Run Code Online (Sandbox Code Playgroud)

如果登录成功,我想根据用户类型将用户从服务器端重定向到适当的页面.如果登录失败,则会将一个字符串发送回用户:

    [HttpPost]
    public ActionResult Index(LoginModel loginData)
    {
        if (login fails)
        {
            return Json("InvalidLogin", JsonRequestBehavior.AllowGet);
        }
        else
        {
             // I want to redirect to another controller, view, or action depending
             // on user type.
        }
    }
Run Code Online (Sandbox Code Playgroud)

但有问题:

  1. 如果此方法返回'ActionResult',那么我收到错误not all code paths …

ajax jquery asp.net-mvc-4

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

ASP.NET5 MVC6中的App_Data目录

我一直在尝试ASP.NET5 MVC6应用程序.在以前的版本中,有一个目录App_Data.我用这个文件夹来存储错误日志.但在最新版本中找不到它.有帮助吗?

asp.net-core-mvc asp.net-core

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

在C#中使用通配符查找文件

我试图从目录中查找文件:

String[] search1 = Directory.GetFiles(voiceSource, "85267-*.wav")
                                 .Select(path => Path.GetFileName(path))
                                 .ToArray();

String[] search2 = Directory.GetFiles(voiceSource, "85267 *.wav")
                                 .Select(path => Path.GetFileName(path))
                                 .ToArray();
Run Code Online (Sandbox Code Playgroud)

但在search1,它选择85267-s.wav85267 -s.wav.但我只想85267-s.wav被选中.

search2 做得很好

我怎样才能做到这一点?

c# file

17
推荐指数
2
解决办法
2924
查看次数

无法解析 primereact 下拉列表中的“react-transition-group”

我收到以下错误 -

Failed to compile
./node_modules/primereact/components/dropdown/DropdownPanel.js
Module not found: Can't resolve 'react-transition-group' in 'D:\my-app\node_modules\primereact\components\dropdown'
Run Code Online (Sandbox Code Playgroud)

这是我的 package.json

  "dependencies": {
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"@types/react-transition-group": "^4.4.1",
"primeflex": "^2.0.0",
"primeicons": "^4.1.0",
"primereact": "^6.1.0",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-scripts": "4.0.3",
"web-vitals": "^1.0.1"
},
Run Code Online (Sandbox Code Playgroud)

在 App.js 中

import React, { useState } from 'react';
import { Dropdown } from 'primereact/dropdown'; //getting error after adding this line
import 'primeflex/primeflex.css';
Run Code Online (Sandbox Code Playgroud)

我在这里缺少什么?

reactjs dropdown primereact

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

在Session_end事件上重定向到另一个页面

我希望在会话超时时自动重定向到登录页面.

在web.config文件中,我有以下代码

<configuration>
    <system.web>
       <sessionState mode="InProc"  timeout="1"/>
    </system.web>
</configuration>
Run Code Online (Sandbox Code Playgroud)

在Global.asax文件中 -

protected void Session_End(object sender, EventArgs e)
{
    Response.Redirect("LoginPage.aspx");
}
Run Code Online (Sandbox Code Playgroud)

但超时后,我收到以下错误:

HttpException未被用户代码处理.

在这种情况下无法获得响应.

有什么线索可以解决这个问题吗?

c# asp.net

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

从事件处理程序在主线程中执行一个方法

我有一个从Queue类继承的自定义Queue类.它有一个事件ItemAdded.在此事件的事件处理程序中,我正在执行一个方法.但它运行的不是主线程,虽然我想在主线程中.我不知道怎么做.有什么建议吗?

//My custom class


using System;
using System.Collections; //Required to inherit non-generic Queue class.

namespace QueueWithEvent
{
    public class SmartQueue:Queue
    {

        public delegate void ItemAddedEventHandler(object sender, EventArgs e);

        public event ItemAddedEventHandler ItemAdded;

        protected virtual void OnItemAdded(EventArgs e)
        {
           if (ItemAdded != null)
           {
              ItemAdded(this, e);
           }
    }

    public override void Enqueue(object Item)
    {
        base.Enqueue(Item);
        OnItemAdded(EventArgs.Empty);
    }        

   }
}



 //Winform application

 using System;
 using System.ComponentModel;
 using System.Windows.Forms;
 using QueueWithEvent;

 namespace TestApp
 {
    public partial class Form1 : Form
    {

    SmartQueue qTest …
Run Code Online (Sandbox Code Playgroud)

c# events multithreading backgroundworker winforms

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

更改winform ToolTip backcolor

我在我的项目中使用ToolTip控件.我想把它的背景颜色设置为红色.我已将ownerdraw属性更改为true,将backcolor更改为红色.但没有结果.有什么建议吗?

此致,skpaul.

c# tooltip winforms

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

Get Source file,method and line in exception

I am trying to get details from an exception occurred in my c# (4.0) asp.net web application. I have .pdb file in bin folder. The following code is not working as expected -

protected void Button1_Click(object sender, EventArgs e)
{
    try
    {
        //throwing Exception
        using (SqlConnection connection=new SqlConnection(""))
        {
            connection.Open();
        }
    }
    catch (Exception exception)
    {
        //Get a StackTrace object for the exception
        StackTrace st = new StackTrace(exception, true);

        //Get the first stack frame
        StackFrame frame = st.GetFrame(0); //returns {PermissionDemand …
Run Code Online (Sandbox Code Playgroud)

.net c# exception

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

chart.js中的水平条形图

我正在尝试使用chart.js 2.3.0绘制一个水平条形图 -

 var MeSeContext = document.getElementById("MeSeStatusCanvas").getContext("2d");
    var MeSeData = {
        labels: [
            "ME",
            "SE"
        ],
        datasets: [
            {
                label: "Test",
                data: [100, 75],
                backgroundColor: ["#669911", "#119966" ],
                hoverBackgroundColor: ["#66A2EB", "#FCCE56"]
            }]
    };

var MeSeChart = new Chart(MeSeContext, {
    type: 'horizontalBar',
    data: MeSeData,
    options: {
        scales: {
            yAxes: [{
                stacked: true
            }]
        }

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

但它只显示一个酒吧.我在这里想念的是什么?

chart.js

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