inconsistent 404 error on API function - c#

I promise I searched for the answer...
My application consist of both a Mobile backend in azure and a Web-client application that makes calls upon this back-end.
I have run across a bizarre bug that creates 404 not found errors when calling a Http Get function on my backend.
The bizarre part of this issue is that the error is random. It is probably a %50 chance that I might get a 404 or a 200 ok response from the server. This only happens on one specific method that was recently added.
I am wondering if breaking the back-end into instances might have created a non-identical copy of my app.
I removed the instance, and the specific api I have been calling is not longer available on the published version it is visible while running on debug.. I get 100% error on the published version now.
What is wrong with azure? cleaning and rebuilding the back-end does nothing.
[Route("api/UserProject/{projectId}")]
[HttpGet]
public HttpResponseMessage GetUserProjectByProjectId(int projectId)
{
//Get all UserProject
List<DTO.User> userList = new List<DTO.User>();
DataTable UserdataTable = SqlHelper.ExecuteDataset("dbo.UserGetByProjectId", projectId).Tables[0];
if (UserdataTable.Rows.Count > 0)
{
foreach (DataRow dataRow in UserdataTable.Rows)
{
DTO.User u = new DTO.User();
Map.DataToObject(dataRow, u);
userList.Add(u);
}
}
return this.Request.CreateResponse(HttpStatusCode.OK, userList);
}
going to the api/help page on Debug the UserProject route works and is shown in DEBUG mode, but as soon as I publish the app the UserProject function is not longer anywhere to be found.

Wow I finally fixed it. I did the one thing I though would be useless and it worked.
I restarted the service from the azure portal....
My opinion: I guess the created intances where the ones working of the latest version while the original was unable to be updated and the only way to make the original update was to restart the whole thing.
I really don't know why this happened, if you guys want to comment on this please do so.

Related

ReactJs.net server side render failing after publish

I just published an application that is working fine in development, but when I upload it to the server it fails when I try to pre-render a specific view.
Simple mvc function returning a view:
public ActionResult StandaloneReport(ReportPageData pageData)
{
return View(pageData);
}
Simple server side render:
#Html.React("Components.ReportDisplayContainer", new {.pageData = Model})
#Html.ReactInitJavaScript()
React.net is set to used a pre-packed js bundle:
ReactSiteConfiguration.Configuration.SetLoadBabel(false)
.AddScriptWithoutTransform("~/Scripts/webpack/build/server.bundle.js");
ReactSiteConfiguration.Configuration.SetReuseJavaScriptEngines(false);
This all works fine in development, and I have republished and deleted all files from the server before publishing so I don't get why it's not working on the server..
The error I am getting is:
Error while rendering "Components.ReportDisplayContainer" to
"react_phCzHNkR5Uq7r5UEzzqYrQ": Script threw an exception: Object
doesn't support property or method 'from' Line: 0 Column:0
Line 61: #Html.React("Components.ReportDisplayContainer", New With {.pageData = Model})
Which I can only see relates to this line of code generated by webpack:
return Array.from(arr);
So why is the react helper happy to do it locally but not on the server?
Not sure if this is exactly what you're experiencing, but I happened upon the solution for my issue after many hours of fruitless experimentation, so hopefully it can help you or someone on the web.
My project has 10 jsx files:
bundles.Add(new System.Web.Optimization.React.BabelBundle("~/bundles/CustomJsxFiles").Include(
"~/Content/ReactJSXFiles/ReactApp.jsx",
"~/Content/ReactJSXFiles/CalendarControl.jsx",
"~/Content/ReactJSXFiles/BootstrapNavbar.jsx",
"~/Content/ReactJSXFiles/SectionList.jsx",
"~/Content/ReactJSXFiles/FutureDPsList.jsx",
"~/Content/ReactJSXFiles/PastDPsList.jsx",
"~/Content/ReactJSXFiles/TimeRecs.jsx",
"~/Content/ReactJSXFiles/ClickableHeader.jsx",
"~/Content/ReactJSXFiles/CodeEntryModal.jsx",
"~/Content/ReactJSXFiles/Dp28DayRow.jsx"
));
and it works fine when debugging locally, but when I published to IIS, I only see 3 files:
ClickableHeader.jsx
ReactApp.jsx
TimeRecs.jsx
FYI, I am using
BundleTable.EnableOptimizations = false;
for debugging purposes. When it's set to true, it creates just one file, but even in that case you can still see that the file is much smaller than the one created locally.
Anyway, at the bottom of the discussion at
http://reactjs.net/guides/weboptimizer.html
I noticed this line:
We just had the same issue, I followed the above instructions. Make
sure the JSX is marked as "content" in the properties.
I look in Visual Studio and the jsx files that were missing were marked none like this:
Whereas the ones that were there were marked like this:
After marking them all as Content, I could successfully push to the server.

Troubleshooting intermittent "No OpenID endpoint found" messages with Google and DotNetOpenAuth

I've been troubleshooting this one off and on for the past week. I've got a site using relying party MVC code from the DotNetOpenAuth project. I've been using this since 2009.
Recently, the Google logins have been failing. I'd say about 80% of the time the Google login works fine. So the intermittent nature makes this hard to diagnose.
Here's what I've tried:
Of course I've verified that the openid_identifier is using the correct URL ( https://www.google.com/accounts/o8/id )
I've updated to the latest release (DotNetOpenAuth 3.4).
I've tried adding default proxy settings as per this answer.
I've extended the timeout settings and even reduced memory on SQL to give IIS more RAM as this answer suggests.
I've added logging to every request and error to see if I could get any valuable information. This doesn't tell me much.
I've watched the requests/responses with Fiddler to see if I could spot anything.
I've tested my Google login on StackOverflow a number of times on the off chance that this is actually a problem with Google. And it's been working every time so far.
Any ideas?
UPDATE
In effort to pinpoint the problem I changed the code on my site a bit. Rather than doing this all on one line...
openid.CreateRequest(Request.Form["openid_identifier"]).RedirectingResponse.AsActionResult();
I broke it up into sections with logging in between...
MvcApplication.Logger.Info("Loading... " + Request.Form["openid_identifier"]);
var request = openid.CreateRequest(Request.Form["openid_identifier"]);
var redirect = request.RedirectingResponse;
MvcApplication.Logger.Info("Status... " + redirect.Status);
if (redirect.Status.ToString().ToLower() != "found")
{
MvcApplication.Logger.Error("Details... " + redirect.Body);
}
return redirect.AsActionResult();
So I'll be waiting for the next error.
I figured it out. This was being caused by New Relic. I'm not sure exactly how (or why it was intermittent) but that's what it was. New Relic automatically instruments your pages in certain ways so maybe it interfered with the request to the OpenID provider.
I looked back at the timeframe in which this all started and found that it was right around the time I installed New Relic on the server. So I uninstalled it, restarted IIS, and let the site go for 48 hours without it. I didn't get a single error in that time. So a couple hours ago I reinstalled it and sure enough I was able to duplicate the problem.
Anyway, I've removed New Relic again and all is good. I'll notify them about this.

WCF - One single method giving error

We have a WCF service and Silverlight app that's been running for a few months now and it's been running fine until today. For some odd reason, there is one method in the service that is giving me an error every time I call it. I've gone so far as commenting out everything the method does, but as soon as I call it from the silverlight app I get that stupid error:NotFound message.
Here's the kicker though... if I run the silverlight app and WCF service on my local machine it runs just fine. It's only when the service is running live on our hosting company's server that I get the error.
Does anyone have ideas??
Getting the error NotFound in a Silverlight Client calling a WCF Service normally means that the service method threw an exception. Without further details we won't be able to help.
I believe I have found the problem. The class that I'm passing through as a parameter looked something like this:
public class MyClass
{
[DataMember]
private string Name = "";
public string _Name
{
get
{
return RegionNameName;
}
set
{
RegionNameName = value;
this.NotifyPropertyChanged("_Name");
}
}
}
The [DataMember] attribute placed on top of the private property seems to have caused the problem. Strange thing is that it did work for the last few months.
Anyway, the guy who wrote it has left the company. So I'll be working through the whole thing now. Not quite what I had in mind for work today.

msxml3.dll error '800c0005'

Really weird problem, I have just moved all our sites to a new Win2008 64bit server with IIS7 (Was on a Win2003 IIS6) and have started having problems with PayPal Pro / PayFlow.
A few of these websites are stores with SSL's and use PayPal Pro to process the payment - Since the move, intermittently I am getting errors like.
msxml3.dll error '800c0005' The
system cannot locate the resource
specified.
Where it seems I cannot connect resolve the PayPal URL to post the data to, as I say this has only started happening since we are on this new server. And what is even more annoying is that its completely intermittent!! Works fine for hours then will throw this error over and over then will be fine again, it effects both the Classic ASP and ASP.NET C# sites using PayPal??
Here is a log file entry if that helps?
2010-07-05 11:34:07 80.100.200.155
POST /scripts/60_Pay.asp
|297|800c0005|The_system_cannot_locate_the_resource_specified.__
443 - 92.8.25.196
Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+6.0;+WOW64;+Sky+Broadband;+GTB6.5;+SLCC1;+.NET+CLR+2.0.50727;+Media+Center+PC+5.0;+.NET+CLR+3.5.21022;+.NET+CLR+3.5.30729;+MDDC;+.NET+CLR+3.0.30729)
500 0 0 1907
Anyone have any ideas on what could be causing this? I was wondering if there was a way to increase the length of time it will wait to try and resolve from the external URL?
Any help would be GREATLY appreciated
Try setting the application pool that you are running this under to run in 32 bit mode and restart IIS. This will at least remove one variable.
Next you should check to see if you can write a very simple asp page that instantiates the xmlhttp object and tries to load a URL to make sure you don't have a network configuration that is preventing the new machine from reaching PayPal's servers (but which allowed the old machine to do so). This could be on your side, or their side.
Finally, are you able to run the code under a debugger on the server so you can figure out what line the error is happening on?

ASP.NET MVC controller method timing out

I'm currently debugging an ASP.NET MVC application that was just deployed to a different server.
All the versions between the staging server and the production server are the same, but in the production server (which is 64bit, but is running the app in 32bit mode) I'm getting a timeout in this controller action:
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Create(Person person, PeopleCertificationLevel peopleCertificationLevel, Address address)
{
try
{
person.PeopleCertificationLevels.Add(peopleCertificationLevel);
person.Addresses.Add(address);
_peopleService.SavePerson(person);
SetMessage("O marĂ­timo foi registado com sucesso.");
return Redirect("~/People/Show/" + person.ID);
}
catch
{
SetErrorMessage("Por favor valide e preencha devidamente os campos assinalados a asterisco (*).");
Create();
return View(person);
}
}
I've already tried throwing an exception before the try block, but I always get a request timeout here.
It seems to me that the request isn't getting to this action. Any suggestions on how I should debug this or what should I do?
UPDATE: I figured it has to do with the model binding. If I remove the bindings, the request gets dispatched, FAST. However, i've tried several approaches, such as using the Bind attribute before the action parameters, tried creating a NewPersonForm class which contained 3 properties (Person, PeopleCertificationLevel, Address), and even tried with a FormCollection and UpdateModel calls. All to no avail.
UPDATE 2: This application is compiled in 32bit and running in a 64bit environment. Although 32bit applications are enabled in the AppPool, I suspect that is what might be causing the problem.
It may not be this silly, but just my 2 cents:
did you actually check if the form is posted through a submit button ?
are all the parameters exactly matching with the names specified in the routing?

Categories

Resources