小编Aru*_*ngh的帖子

使用partialview时,HttpPostedFileBase始终为null

我正在开发一个使用自定义模式弹出窗口在服务器上上传pdf文件的应用程序.我正在使用文件上传浏览器html控件来上传.pdf文件,此控件是在部分视图中设计的.当我点击"添加"按钮然后在服务器端我没有得到HttpPostedFileBase和FormCollection值.

这是我的代码:

局部视图:

@model Zytron.Models.ProductDataControls

    @using (Html.BeginForm("UploadFiles", "AdminPanel", FormMethod.Post, new
    {
        @id = "file_upload",
    }))

    {

        <table width="100%" cellpadding="5" cellspacing="1">
            <tr>
                <td>
                    <span>Description</span>
                </td>
            </tr>
            <tr>
                <td>
                    @Html.TextBoxFor(m => m.Description, new
               {
                   @class = "textBox"
               })
                    @Html.HiddenFor(m => m.ProductId)
                    @Html.HiddenFor(m => m.ParentId)
                </td>
            </tr>
            <tr>
                <td>
                    <span>File Source</span>
                </td>
            </tr>
            <tr>
                <td>
                    <input type="file" id="fileUpload" name="fileUpload" size="23" />
                </td>
            </tr>
        </table>
    }
Run Code Online (Sandbox Code Playgroud)

型号代码:

public class ProductDataControls

 {



       public string Description { get; set; }

  }
Run Code Online (Sandbox Code Playgroud)

自定义模态弹出代码:

function loadProdAttachFile(tag, event, target) …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc razor

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

该类型不能分配给服务autofac

我有这样的界面:

public interface ICategoryFacade
{
    IEnumerable<Category> Get();
    Category Get(int id);
    int Post(Category model);
    int Put(Category model);
    int Patch(Category model);
    int Delete(int id);

} 
Run Code Online (Sandbox Code Playgroud)

我上课了:

public class CategoryFacade : ICategoryFacade
{
    MyContext _dbContext = new MyContext ();

    public IEnumerable<Category> Get()
    {
        return _dbContext.Categories;
    }
    public Category Get(int id)
    {
        return _dbContext.Categories.FirstOrDefault(m => m.CategoryID == id);
    }
    public int Post(Category model)
    {
        return 0;
    }
    public int Put(Category model)
    {
        return 0;
    }
    public int Patch(Category model)
    {
        return 0;
    }
    public …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc autofac odata asp.net-web-api

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

标签 统计

asp.net-mvc ×2

asp.net-web-api ×1

autofac ×1

odata ×1

razor ×1