小编Lam*_*fif的帖子

上传文件并过滤其扩展名

我有一个ASP.Net Web应用程序,我必须上传一个文件:

@using (Html.BeginForm("Uploading_validation", "Super", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
    <input type="file" name="dossier"  accept="*.iso, *.rar, *.zip"/>
   <br />
    @Html.Label("Date d'expiration")

    <input type="text" id="datepicker" name="duree" />
    <br />
 <input type="submit" value="OK" />
 }
Run Code Online (Sandbox Code Playgroud)

我只想接受扩展accept="*.iso, *.rar, *.zip",但它不起作用.

为什么这个过滤器不起作用?我该如何修改代码?

.net c# asp.net-mvc file-upload razor

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

修复global.asax中的语法错误

我有一个asp.net mvc4应用程序。我的Global.asax档案有问题

演示

Global.asax.cs中

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.Mvc;
using System.Web.Routing;

namespace integration_finale
{

    public class MvcApplication : System.Web.HttpApplication
    {
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

当我启动应用程序时,出现此错误:

演示2

翻译成英文

“ /”应用程序中的服务器错误。分析错误说明:在满足此需求资源的需求分析期间发生错误。请在下面查看有问题的错误分析的详细信息,并适当地修改您的源文件。

消息解析器错误:无法加载类型'integration_finale.MvcApplication'。

源错误:

第1行:<%@ Application Codebehind =“ Global.asax.cs” Inherits =“ integration_finale.MvcApplication”语言=“ C#”%>

源文件:/ global.asax行:1

版本信息:Microsoft NET Framework版本:。4.0.30319; ASP.NET版本:4.0.30319.18056

那么问题是什么,我该如何解决?

.net c# asp.net asp.net-mvc asp.net-mvc-4

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

从ms访问应用程序导出整个vba代码

我有一个ms访问应用程序(ms access 2013),我想将所有vba代码导出到文件夹中的单独文件

我可以添加什么代码来执行此操作?

谢谢,

directory ms-access vba export file

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

表达式不会在vb.net应用程序中生成值

我有一个Winforms应用程序,我想在其中使用MVVM设计模式:

我按照本教程

这是非常有趣的文章,但我遇到了这个问题:我的应用程序是vb.net,我将代码(C#)转换为vb.net,除了这个之外它工作正常:

C#代码

 protected void ViewModel_Validated(object sender, EventArgs e)
    {
        this.ViewModel.AttachedControls.ToList().ForEach(c => this.errorProvider.SetError(c.Value as Control, ""));
        if (!string.IsNullOrEmpty(this.ViewModel.Error)) {
            this.ViewModel.Messages.ToList().ForEach(message => {
                this.errorProvider.SetError(this.ViewModel.AttachedControls[message.Key] as Control, message.Value);
            });
        }
    } 
Run Code Online (Sandbox Code Playgroud)

Vb.net代码

 Protected Sub ViewModel_Validated(ByVal sender As Object, ByVal e As EventArgs)
        Me.ViewModel.AttachedControls.ToList().ForEach(Function(c) Me.errorProvider.SetError(TryCast(c.Value, Control), ""))
        If Not String.IsNullOrEmpty(Me.ViewModel.[Error]) Then
            Me.ViewModel.Messages.ToList().ForEach(Function(message)
                                                       Me.errorProvider.SetError(TryCast(Me.ViewModel.AttachedControls(message.Key), Control), message.Value)

                                                   End Function)
        End If
    End Sub
Run Code Online (Sandbox Code Playgroud)

问题出在这一行:

Me.ViewModel.AttachedControls.ToList().ForEach(Function(c) Me.errorProvider.SetError(TryCast(c.Value, Control), ""))
Run Code Online (Sandbox Code Playgroud)

错误:

Expression does not produce a value.

我需要知道

  • 这个错误的原因是什么?
  • 我该如何解决?

.net c# vb.net mvvm winforms

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

使用owin和ninject在webapi应用程序中的无参数构造函数问题

我有一个web api应用程序,我想使用Owin,OauthNinject,所以我有这个配置

依赖注入器

public class NinjectDependencyResolver : IDependencyResolver
{
    private static IKernel kernel; 

    public NinjectDependencyResolver()
    {
        kernel = new StandardKernel();
       // AddBindings();
    }

    public object GetService(Type serviceType)
    {
        return kernel.TryGet(serviceType);
    }

    public IEnumerable<object> GetServices(Type serviceType)
    {
        return kernel.GetAll(serviceType);
    }

    private static void AddBindings()
    {
        kernel.Bind<INotifier>().To<Notifier>();
        kernel.Bind<IEventRepository>().To<EventRepository>();
        kernel.Bind<ICrud<Config>>().To<CrudConfig>();
        kernel.Bind<ICrud<Evenement>>().To<CrudEvent>();
        kernel.Bind<IAccount>().To<Account>();
    }



    public static Lazy<IKernel> CreateKernel = new Lazy<IKernel>(() =>
    {
        //var kernel = new StandardKernel();
        kernel.Load(Assembly.GetExecutingAssembly());
        kernel.Bind<Func<IKernel>>().ToMethod(ctx => () => new Bootstrapper().Kernel);
        kernel.Bind<IHttpModule>().To<HttpApplicationInitializationHttpModule>();
        AddBindings();

        return …
Run Code Online (Sandbox Code Playgroud)

.net c# ninject asp.net-web-api owin

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

在asp.net web api应用程序中找不到命名空间System.Web.Http.Results

我有一个asp.net web api应用程序,其中我有这一行:

using System.Web.Http.Results;
Run Code Online (Sandbox Code Playgroud)

我的问题是命名空间无法识别,我验证system.Web.Http了bin文件夹中存在的dll !!

所以我需要知道:

  • 这个问题的原因是什么?
  • 我该如何解决?

.net asp.net-mvc .net-assembly asp.net-web-api system.web.http

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

系统数据SqlClient SqlException

我必须执行更新查询:

 using (SqlCommand sqlCmd = new SqlCommand("UPDATE  Test SET Testedpiece = Testedpiece + 1 and Rate = (Testedpiece  * 100) / Totalpiece  WHERE IDSuperlot = @super", connexion))
Run Code Online (Sandbox Code Playgroud)

但我有这个错误 System.Data.SqlClient.SqlException (0x80131904): Incorrect syntax near the keyword 'and'.

我不知道为什么会出现这个错误,我该如何解决它

  1. 什么是Sql语法错误?
  2. 我该如何解决?

.net c# sql sql-server ado.net

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

重定向到剃须刀应用程序中的另一个网站

我想在我的Asp.net mvc4应用程序中添加一个链接google.com.所以我将这个片段添加到我的视图中:

 <p class="art-page-footer">
        <span id="art-footnote-links"><a href="www.google.com" target="_blank">google.com</a></span>
    </p>
Run Code Online (Sandbox Code Playgroud)

当我点击这个链接我有一个网址http://localhost:61961/User/www.google.com,我有一个例外.

那么为什么这个重定向不起作用呢?我该如何修复我的代码?

.net c# asp.net asp.net-mvc asp.net-mvc-4

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

在asp.net web api应用程序中找不到Json类型

我的asp.net web api应用程序中有这个控制器:

using AutoMapper;
using Microsoft.AspNet.Identity.EntityFramework;
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.Owin;  
using Microsoft.Owin.Security;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using System.Web;
using System.Web.WebPages.Html;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Text.RegularExpressions;
using System.Net.Mail;


namespace AjTransport.webApi.Controllers 
{
    public class AccountManageController : ApiController
    {

        [AllowAnonymous]
        public System.Web.Mvc.JsonResult FindUser(string str)
        {
            var result = UserManager.FindByName(str) ??   UserManager.FindByEmail(str);
             return Json(result == null, System.Web.Mvc.JsonRequestBehavior.AllowGet);
        }
}
}
Run Code Online (Sandbox Code Playgroud)

问题出在这里

return Json(result == null,System.Web.Mvc.JsonRequestBehavior.AllowGet);

找不到类型Json.所以我需要知道如何解决这个问题?

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

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

在 linq 中使用反射和 lambda 表达式

我需要通过验证名为的标志的值来过滤项目集合 deletion_date

 public List<T> GetAll()
 {
   if (context == null) context = new ajtdevEntities();
   return context.Set<T>().Where(p => p.GetType().GetProperty("deletion_date") == null).ToList();
 }
Run Code Online (Sandbox Code Playgroud)

使用此通用方法时出现异常

LINQ to Entities 无法识别方法 'System.Reflection.PropertyInfo GetProperty (System.String)',并且后者无法转换为术语库。

我该如何解决这个方法?

.net c# linq generics reflection

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