问题:

我刚刚将服务器(Windows 2012R2)从先前的.Net Core 1.0 RC2更新为.Net Core 1.0 RTM Windows Hosting Pack。 我的应用程序可以在PC上正常运行,但服务器始终显示:

HTTP Error 502.5 - Process Failure


Common causes of this issue:

The application process failed to start
The application process started but then stopped
The application process started but failed to listen on the configured port

它以前与RC2版本一起使用。 不知道会出什么问题。

这就是事件查看器说的所有内容:

Failed to start process with the commandline 'dotnet .\MyWebApp.dll'. Error code = '0x80004005'.

最糟糕的是,应用程序日志为空! 我的意思是那些stdout_xxxxxxxxx.log文件完全为空,并且所有字节均为0。

我该怎么办?? 未记录错误时如何知道错误原因?

I just updated my server (Windows 2012R2) to .Net Core 1.0 RTM Windows Hosting pack from the previous .Net Core 1.0 RC2 .My app works on my PC without any issues but the server keeps showing:It previously worked with the RC2 version.Don’t know what could go wrong.This is all event viewer says:the worst part is that app logs are empty!I mean those stdout_xxxxxxxxx.log files are completely empty and all have 0 byte size.What should I do??How can I know the cause of error when it’s not logged??

问题:

几天前,我将解决方案移到了MSVS2013。除了一件事,它可以正常工作:当我尝试调试WCF服务的代码时,它可以工作,但是当我要监视任何变量的状态时,它说:“表达式中的内部错误评估者”。 添加监视功能在客户端可以正常使用,但是在服务代码中却坏了。 我正在尝试调试在本地主机上运行的WCF服务。 您能帮我,如何修复?

在此处输入图片说明

此处的MSVS信息:Microsoft Visual Studio Professional 2013版本12.0.30110.00更新1 Microsoft .NET Framework版本4.5.51641操作系统:Windows 8.1

Few days ago I moved my solution to MSVS 2013. It works fine except one thing: when I trying to debug code of my WCF service it works, but when I want to watch state of any variable it says: “Internal error in the expression evaluator”.Add watch function works normal on client side, but in service code it broken.I’m trying to debug my own WCF service running on the localhost.Could you help me, how to repair this?Here MSVS info: Microsoft Visual Studio Professional 2013 Version 12.0.30110.00 Update 1 Microsoft .NET Framework Version 4.5.51641 OS: Windows 8.1

问题:

这是在我的Web API上调用PUT方法 – 方法的第三行(我从ASP.NET MVC前端调用Web API):

在此输入图像描述

client.BaseAddresshttp://localhost/CallCOPAPI/

这是contactUri :

在此输入图像描述

这是contactUri.PathAndQuery :

在此输入图像描述

最后,这是我的405回复:

在此输入图像描述

这是我的Web API项目中的WebApi.config:

        public static void Register(HttpConfiguration config)
        {
            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );

            config.Routes.MapHttpRoute(
                name: "DefaultApiGet",
                routeTemplate: "api/{controller}/{action}/{regionId}",
                defaults: new { action = "Get" },
                constraints: new { httpMethod = new HttpMethodConstraint("GET") });

            var json = config.Formatters.JsonFormatter;
            json.SerializerSettings.PreserveReferencesHandling = Newtonsoft.Json.PreserveReferencesHandling.Objects;
            config.Formatters.Remove(config.Formatters.XmlFormatter);

我已经尝试将传递给PutAsJsonAsync的路径剥离到string.Format("/api/department/{0}", department.Id)string.Format("http://localhost/CallCOPAPI/api/department/{0}", department.Id)没有运气。

有没有人有任何想法为什么我得到405错误?

UPDATE

根据请求,这是我的部门控制器代码(我将发布我的前端项目的部门控制器代码,以及WebAPI的部门ApiController代码):

前端部门控制员

namespace CallCOP.Controllers
{
    public class DepartmentController : Controller
    {
        HttpClient client = new HttpClient();
        HttpResponseMessage response = new HttpResponseMessage();
        Uri contactUri = null;

        public DepartmentController()
        {
            // set base address of WebAPI depending on your current environment
            client.BaseAddress = new Uri(ConfigurationManager.AppSettings[string.Format("APIEnvBaseAddress-{0}", CallCOP.Helpers.ConfigHelper.COPApplEnv)]);

            // Add an Accept header for JSON format.
            client.DefaultRequestHeaders.Accept.Add(
                new MediaTypeWithQualityHeaderValue("application/json"));
        }

        // need to only get departments that correspond to a Contact ID.
        // GET: /Department/?regionId={0}
        public ActionResult Index(int regionId)
        {
            response = client.GetAsync(string.Format("api/department/GetDeptsByRegionId/{0}", regionId)).Result;
            if (response.IsSuccessStatusCode)
            {
                var departments = response.Content.ReadAsAsync<IEnumerable<Department>>().Result;
                return View(departments);
            }
            else
            {
                LoggerHelper.GetLogger().InsertError(new Exception(string.Format(
                    "Cannot retrieve the list of department records due to HTTP Response Status Code not being successful: {0}", response.StatusCode)));
                return RedirectToAction("Index");
            }

        }

        //
        // GET: /Department/Create

        public ActionResult Create(int regionId)
        {
            return View();
        }

        //
        // POST: /Department/Create
        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Create(int regionId, Department department)
        {
            department.RegionId = regionId;
            response = client.PostAsJsonAsync("api/department", department).Result;
            if (response.IsSuccessStatusCode)
            {
                return RedirectToAction("Edit", "Region", new { id = regionId });
            }
            else
            {
                LoggerHelper.GetLogger().InsertError(new Exception(string.Format(
                    "Cannot create a new department due to HTTP Response Status Code not being successful: {0}", response.StatusCode)));
                return RedirectToAction("Edit", "Region", new { id = regionId });
            }
        }

        //
        // GET: /Department/Edit/5

        public ActionResult Edit(int id = 0)
        {
            response = client.GetAsync(string.Format("api/department/{0}", id)).Result;
            Department department = response.Content.ReadAsAsync<Department>().Result;
            if (department == null)
            {
                return HttpNotFound();
            }
            return View(department);
        }

        //
        // POST: /Department/Edit/5

        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Edit(int regionId, Department department)
        {
            response = client.GetAsync(string.Format("api/department/{0}", department.Id)).Result;
            contactUri = response.RequestMessage.RequestUri;
            response = client.PutAsJsonAsync(string.Format(contactUri.PathAndQuery), department).Result;
            if (response.IsSuccessStatusCode)
            {
                return RedirectToAction("Index", new { regionId = regionId });
            }
            else
            {
                LoggerHelper.GetLogger().InsertError(new Exception(string.Format(
                    "Cannot edit the department record due to HTTP Response Status Code not being successful: {0}", response.StatusCode)));
                return RedirectToAction("Index", new { regionId = regionId });
            }
        }

        //
        // GET: /Department/Delete/5

        public ActionResult Delete(int id = 0)
        {
            response = client.GetAsync(string.Format("api/department/{0}", id)).Result;
            Department department = response.Content.ReadAsAsync<Department>().Result;

            if (department == null)
            {
                return HttpNotFound();
            }
            return View(department);
        }

        //
        // POST: /Department/Delete/5

        [HttpPost, ActionName("Delete")]
        [ValidateAntiForgeryToken]
        public ActionResult DeleteConfirmed(int regionId, int id)
        {
            response = client.GetAsync(string.Format("api/department/{0}", id)).Result;
            contactUri = response.RequestMessage.RequestUri;
            response = client.DeleteAsync(contactUri).Result;
            return RedirectToAction("Index", new { regionId = regionId });
        }
    }
}

Web API部门ApiController

namespace CallCOPAPI.Controllers
{
    public class DepartmentController : ApiController
    {
        private CallCOPEntities db = new CallCOPEntities(HelperClasses.DBHelper.GetConnectionString());

        // GET api/department
        public IEnumerable<Department> Get()
        {
            return db.Departments.AsEnumerable();
        }

        // GET api/department/5
        public Department Get(int id)
        {
            Department dept = db.Departments.Find(id);
            if (dept == null)
            {
                throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            return dept;
        }

        // this should accept a contact id and return departments related to the particular contact record
        // GET api/department/5
        public IEnumerable<Department> GetDeptsByRegionId(int regionId)
        {
            IEnumerable<Department> depts = (from i in db.Departments
                                             where i.RegionId == regionId 
                                             select i);
            return depts;
        }

        // POST api/department
        public HttpResponseMessage Post(Department department)
        {
            if (ModelState.IsValid)
            {
                db.Departments.Add(department);
                db.SaveChanges();

                HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, department);
                return response;
            }
            else
            {
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
            }
        }

        // PUT api/department/5
        public HttpResponseMessage Put(int id, Department department)
        {
            if (!ModelState.IsValid)
            {
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
            }

            if (id != department.Id)
            {
                return Request.CreateResponse(HttpStatusCode.BadRequest);
            }

            db.Entry(department).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException ex)
            {
                return Request.CreateErrorResponse(HttpStatusCode.NotFound, ex);
            }

            return Request.CreateResponse(HttpStatusCode.OK);
        }

        // DELETE api/department/5
        public HttpResponseMessage Delete(int id)
        {
            Department department = db.Departments.Find(id);
            if (department == null)
            {
                return Request.CreateResponse(HttpStatusCode.NotFound);
            }

            db.Departments.Remove(department);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException ex)
            {
                return Request.CreateErrorResponse(HttpStatusCode.NotFound, ex);
            }

            return Request.CreateResponse(HttpStatusCode.OK, department);
        }
    }
}

Here’s the call to the PUT method on my Web API – the third line in the method (I am calling the Web API from an ASP.NET MVC front end):client.BaseAddress is http://localhost/CallCOPAPI/ .Here’s contactUri :Here’s contactUri.PathAndQuery :And finally, here’s my 405 response:Here’s the WebApi.config in my Web API project:I’ve tried stripping down the path that gets passed into PutAsJsonAsync to string.Format("/api/department/{0}", department.Id) and string.Format("http://localhost/CallCOPAPI/api/department/{0}", department.Id) with no luck.Does anyone have any ideas why I’m getting the 405 error?UPDATEAs per request, here’s my Department controller code (I will post both the Department controller code for my front end project, as well as the Department ApiController code for the WebAPI):Front End Department ControllerWeb API Department ApiController

问题:

我在Windows Azure上部署了我的MVC-3应用程序。 但现在当我通过staging url请求它时,它会显示给我(抱歉,处理您的请求时出错) 现在我想看到完整的错误消息,默认情况下它隐藏了一些安全原因。 我知道我们可以通过web.config文件执行此操作。 但是怎么样?

I deployed my MVC-3 application on windows Azure.But now when I am requesting it through staging url it shows me (Sorry, an error occurred while processing your request.) .Now I want to see the full error message, by default it is hiding that because of some security reasons.I know that we can do this through web.config file.But how?

问题:

我有一个WebApplication,其中包含对WCF服务的引用。

使用Visual Studio 2010进行构建时,构建失败,没有任何错误或警告。 但是,使用MsBuild构建.csproj是成功的。

无法弄清楚我应该在Visual Studio中尝试什么来解决/诊断问题。 你能帮忙吗?

编辑:

我发现构建失败了,

  1. 来自状态栏中显示的文本。
    在此处输入图片说明

  2. 从输出窗口:

     ========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ========== 

I have a WebApplication which contains reference to WCF services.While building using Visual Studio 2010, Build fails without any error or warning.However building the .csproj using MsBuild is successful.Can’t figure out what should I try in Visual Studio, to resolve / diagnose the issue.Can you please help out?EDIT:I find out that the build has been failing,From text displayed in status Bar.From output window :