mauricioaniche / restfulie.net Goto Github PK
View Code? Open in Web Editor NEW.net version of restfulie server
Home Page: http://restfulie.caelum.com.br
License: Other
.net version of restfulie server
Home Page: http://restfulie.caelum.com.br
License: Other
I'm not sure if this is some kind of compound issue as I couldn't seem to reproduce this directly in the sample Web.csproj on restfulie.
I'm having an issue where I respond to a regular browser request after checking the Request.Headers["If-Modified-Since"] with a new NotModified() restfulie result. Instead of it returning to the browser immediately, it actually tries to respond with the view which then blows up spectacularly because the model is null.
As a temporary work around I had to create this class:
public class ReallyNotModified : ActionResult
{
public override void ExecuteResult(ControllerContext context)
{
var response = context.HttpContext.Response;
response.StatusCode = 304;
response.StatusDescription = "Not Modified";
new EmptyResult().ExecuteResult(context);
}
}
And respond with this instead of the restfulie result.
The built in JSON serializers return JSON dates in a nonstandard format which results in invalid JSON that cannot be used with jquery (at the minimum).
Please see my comments on #11 for more depth.
Accept: text/html,application/xhtml+xml,application/xml;image/png,image/jpeg,image/;q=0.9,/*;q=0.8
This will crash
AcceptHeaderToMediaType
private FormatPlusQualifier ParseFormat(string type)
if (ContainsQualifier(type))
{
var typeInfo = type.Split(';');
format = typeInfo[0].Trim();
qualifier = Convert.ToDouble(typeInfo[1].Split('=')[1], new CultureInfo("en-US"));
}
This gets an instance of "application/xml;image/png" which it then splits at the ; and then tries to resplit on =, however since there is no = at all, typeInfo[1] is out of bounds of the array.
System.IndexOutOfRangeExceptionIndex was outside the bounds of the array.
System.IndexOutOfRangeException: Index was outside the bounds of the array.
at Restfulie.Server.Negotiation.AcceptHeaderToMediaType.ParseFormat(String type)
at Restfulie.Server.Negotiation.AcceptHeaderToMediaType.GetMediaType(String acceptHeader)
at Restfulie.Server.ActAsRestfulie.OnActionExecuting(ActionExecutingContext filterContext)
[TestFixture]
public class AcceptHeaderToMediaTypeTests
{
[Test]
public void shouldwork()
{
var mediaType = acceptHeader.GetMediaType("text/html,application/xhtml+xml,application/xml;image/png,image/jpeg,image/*;q=0.9,*/*;q=0.8");
}
Considere o seguinte código:
public ActionResult Edicao(long id)
{
T lido = repo.Procura(id);
if (lido == null)
return new NotFound();
return new OK(lido);
}
Usando o $("#container").load() do jQuery, o restfulie tenta retorna a view, e como não foi passado nenhum modelo para a view, é lançado NullReferenceException, chegando erro 500 no client.
Deveria retorna um 404, correto?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.