问题描述
最近遇到一个问题,需要部署一个网站,提供Gateway控制器下面的Send方法出来供其他程序调用,比如有2台服务器,101和102,都部署在8201端口,在101服务器上地址栏输入http://localhost:8201/gateway/send能访问,而在102服务器上输入http://localhost:8201/gateway/send就会报错误提示,以下为详情,求大神们帮忙看下什么问题。ServerErrorin'/'Application.--------------------------------------------------------------------------------SecurityExceptionDescription:Theapplicationattemptedtoperformanoperationnotallowedbythesecuritypolicy.Tograntthisapplicationtherequiredpermissionpleasecontactyoursystemadministratororchangetheapplication'strustlevelintheconfigurationfile.ExceptionDetails:System.Security.SecurityException:Thesourcewasnotfound,butsomeoralleventlogscouldnotbesearched.Tocreatethesource,youneedpermissiontoreadalleventlogstomakesurethatthenewsourcenameisunique.Inaccessiblelogs:Security.SourceError:Anunhandledexceptionwasgeneratedduringtheexecutionofthecurrentwebrequest.Informationregardingtheoriginandlocationoftheexceptioncanbeidentifiedusingtheexceptionstacktracebelow.StackTrace:[SecurityException:Thesourcewasnotfound,butsomeoralleventlogscouldnotbesearched.Tocreatethesource,youneedpermissiontoreadalleventlogstomakesurethatthenewsourcenameisunique.Inaccessiblelogs:Security.]System.Diagnostics.EventLogInternal.FindSourceRegistration(Stringsource,StringmachineName,BooleanreadOnly,BooleanwantToCreate)+664System.Diagnostics.EventLogInternal.SourceExists(Stringsource,StringmachineName,BooleanwantToCreate)+109System.Diagnostics.EventLogInternal.VerifyAndCreateSource(StringsourceName,StringcurrentMachineName)+91System.Diagnostics.EventLogInternal.WriteEntry(Stringmessage,EventLogEntryTypetype,Int32eventID,Int16category,Byte[]rawData)+201System.Diagnostics.EventLog.WriteEntry(Stringsource,Stringmessage,EventLogEntryTypetype,Int32eventID,Int16category,Byte[]rawData)+108System.Diagnostics.EventLog.WriteEntry(Stringsource,Stringmessage,EventLogEntryTypetype)+16Gateway.Controllers.GatewayController.Send(StringenterpriseId,StringuserName,Stringpassword,Stringtelphone,StringtasksId,Stringcontent)+97lambda_method(Closure,ControllerBase,Object[])+347System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBasecontroller,Object[]parameters)+17System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContextcontrollerContext,IDictionary`2parameters)+188System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContextcontrollerContext,ActionDescriptoractionDescriptor,IDictionary`2parameters)+27System.Web.Mvc.<>c__DisplayClassd.<InvokeActionMethodWithFilters>b__a()+56System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilterfilter,ActionExecutingContextpreContext,Func`1continuation)+267System.Web.Mvc.<>c__DisplayClassf.<InvokeActionMethodWithFilters>b__c()+20System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContextcontrollerContext,IList`1filters,ActionDescriptoractionDescriptor,IDictionary`2parameters)+190System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContextcontrollerContext,StringactionName)+329System.Web.Mvc.Controller.ExecuteCore()+115System.Web.Mvc.ControllerBase.Execute(RequestContextrequestContext)+42System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContextrequestContext)+10System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__4()+34System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0()+21System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult_)+12System.Web.Mvc.Async.WrappedAsyncResult`1.End()+55System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResultasyncResult)+30System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResultresult)+9System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()+8836977System.Web.HttpApplication.ExecuteStep(IExecutionStepstep,Boolean&completedSynchronously)+184--------------------------------------------------------------------------------VersionInformation:Microsoft.NETFrameworkVersion:4.0.30319;ASP.NETVersion:4.0.30319.1
解决方案
解决方案二:
该方法代码如下