Skip to content

Commit

Permalink
syncing source controls
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick Berardi committed Aug 10, 2010
1 parent ae760f6 commit 3a8d8c8
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 24 deletions.
14 changes: 7 additions & 7 deletions Source/ManagedFusion.Web.csproj
Expand Up @@ -10,7 +10,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ManagedFusion</RootNamespace>
<AssemblyName>ManagedFusion.Web</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SccProjectName>
</SccProjectName>
Expand Down Expand Up @@ -130,12 +130,6 @@
<Compile Include="Web\Mvc\UnsupportedMediaTypeResult.cs" />
<Compile Include="Web\Mvc\XmlResult.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\ManagedFusion\Source\ManagedFusion.csproj">
<Project>{92F1B19A-91D8-4F24-99D8-40042F86855D}</Project>
<Name>ManagedFusion</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
Expand All @@ -153,6 +147,12 @@
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\ManagedFusion\Source\ManagedFusion.csproj">
<Project>{92F1B19A-91D8-4F24-99D8-40042F86855D}</Project>
<Name>ManagedFusion</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
46 changes: 29 additions & 17 deletions Source/Web/Mvc/SerializedResult.cs
Expand Up @@ -92,32 +92,44 @@ public static ResponseType GetResponseType(ControllerContext filterContext)
// check to see if we should try to parse it to an enum
responseType = ManagedFusion.Utility.ParseEnum<ResponseType>(type);

// if the response type is still the default HTML check the Accept header
// if the requestion is an XMLHttpRequest
var acceptTypes = filterContext.HttpContext.Request.AcceptTypes;

if (responseType == ResponseType.None && filterContext.HttpContext.Request.AcceptTypes != null)
{
foreach (string accept in filterContext.HttpContext.Request.AcceptTypes)
if (acceptTypes.Any(x => x.StartsWith("text/html") || x.StartsWith("application/xhtml+xml")))
responseType = ResponseType.Html;

if (responseType == ResponseType.None)
{
switch (accept.ToLower())
foreach (string accept in acceptTypes)
{
case "application/xhtml+xml":
case "text/html": responseType = ResponseType.Html; break;
var value = accept;
var seperatorIndex = value.IndexOf(';');

case "application/json":
case "application/x-json": responseType = ResponseType.Json; break;
if (seperatorIndex > -1)
value = value.Substring(0, seperatorIndex);

case "application/javascript":
case "application/x-javascript":
case "text/javascript": responseType = ResponseType.JavaScript; break;
switch (accept.ToLower())
{
case "application/xhtml+xml":
case "text/html": responseType = ResponseType.Html; break;

case "application/xml":
case "text/xml": responseType = ResponseType.Xml; break;
case "application/json":
case "application/x-json": responseType = ResponseType.Json; break;

case "text/csv": responseType = ResponseType.Csv; break;
}
case "application/javascript":
case "application/x-javascript":
case "text/javascript": responseType = ResponseType.JavaScript; break;

if (responseType != ResponseType.None)
break;
case "application/xml":
case "text/xml": responseType = ResponseType.Xml; break;

case "text/csv": responseType = ResponseType.Csv; break;
}

if (responseType != ResponseType.None)
break;
}
}
}

Expand Down

0 comments on commit 3a8d8c8

Please sign in to comment.