1

我目前正在构建一个 ASP.Net MVC3 网站并使用 ckeditor 作为我的 wsywig。从 Visual Studio 部署服务器时,一切正常,但是当我出于某种原因在 IIS7.5 上设置网站时,发布的文件一直返回为空。

这是 UploadController 文件中的代码:

public ActionResult Upload(HttpPostedFileBase upload, string CKEditorFuncNum, string CKEditor, string langCode)
    {
        string fileName = upload.FileName;

        string basePath = Server.MapPath("~/Uploads");
        upload.SaveAs(basePath + "\\" + fileName);

        return View();
    }

HttpPostedFileBase 上传一直为空。

这是 ckeditor config.js 文件中的代码:

   CKEDITOR.editorConfig = function( config )
{
    config.filebrowserBrowseUrl = "/Admin/Uploads/Browse";
    config.filebrowserWindowWidth = 500;
    config.filebrowserWindowHeight = 650;
    config.filebrowserUploadUrl = "/Admin/Uploads/Upload";
};

这是堆栈跟踪:

    System.NullReferenceException: Object reference not set to an instance of an object.
   at SOSWebCMS.Areas.Admin.Controllers.UploadsController.Upload(HttpPostedFileBase upload, String CKEditorFuncNum, String CKEditor, String langCode) in **C:\Documents\SOSWebCMS\Areas\Admin\Controllers\UploadsController.cs:line 31**
   at lambda_method(Closure , ControllerBase , Object[] )
   at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
   at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
   at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12()
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)
   at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass15.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14()
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
   at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)
   at System.Web.Mvc.Controller.ExecuteCore()
   at System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext)
   at System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext)
   at System.Web.Mvc.MvcHandler.<>c__DisplayClass6.<>c__DisplayClassb.<BeginProcessRequest>b__5()
   at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass1.<MakeVoidDelegate>b__0()
   at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.End()
   at System.Web.Mvc.MvcHandler.<>c__DisplayClasse.<EndProcessRequest>b__d()
   at System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f)
   at System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action)
   at System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)
   at System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result)
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

我确实注意到的一件事是控制器操作的路径是我的本地主机的路径,而不是我的实时环境中的正确路径。考虑到它似乎确实引用了文件中的正确行,不确定这是否有任何限制。

我已经给了 MachineName\IIS_IUSRS 所有适当的权限,所以我知道这不是权限问题。

如果您需要我发布其他任何内容,请告诉我。

4

0 回答 0