Safely remove Newtonsoft.Json reference from ASP.NET MVC4 Project - json

In my ASP.NET MVC4 Application, I don't need to use Web API.
All I want is to use JsonResult in System.Web.Mvc. Is it safe to remove the package Newtonsoft.Json from my reference?
It seems to be added by default when creating an ASP.NET MVC4 application, so I am afraid removing it will cause problem to asp.net mvc framework.

You can't because Microsoft.AspNet.WebApi.Core has a dependency on it. This package adds support to format and content negotiation to HTTP messages. It allows you to use Web APIs like:
http://example/api/attributes/?category=value
You can find more details here.

I noticed that if you are including some google references in your bin folder:
Google.GData.Client.dll
Google.GData.Extensions.dll
Google.GData.Youtube.dll
this caused Newtonsoft.Json.dll to be added back into the project and bin folder during build.

Related

My new CSProj is using SDK format but MVC Razor views are targetting AspNetCore and not AspNet

I've created a ASP.NET Web Application .NET Framework project, and when I convert the CSProj file to use SDK format, my Razor view targets Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper instead of System.Web.Mvc HtmlHelper.
Is this a feature of the SDK projects?
Is there is no support for Razor in a .Net Framework world at this time?
Will there be?
The new MsBuild format is so nice ... I want it for my projects, REALLY badly.

The name 'model' does not exist in current context in ASP.NET Core

I'm trying to develop a website with plugins using ASP.NET Core. I have my main project, asp.net web application which works fine. I have a class library project with controllers which also works fine and views which I have a problem with. When I open *.cshtml file I can see that Razor doesn't work - #using, #model and other directives are not recognized and intellisense doesn't work. When I hover over model I'm given the error from title:
The name 'model' does not exist in current context in ASP.NET Core
I use EmbeddedFileProvider for discovering views and they're marked as Embedded resource. When I run application everything works - views are rendered correctly. My only issue is false-positive errors in Visual Studio. I googled and there similar issues, but mainly for ASP.NET MVC, not Core - like here. I think something is missing in class library configuration, but I'm not sure what exactly.
The new csproj file has an "Sdk" attribute at the top level "Project" element. When you create a new Web application, this gets set to the "Web" SDK:
<Project Sdk="Microsoft.NET.Sdk.Web">...</Project>
When you add/create a class library, it defaults to the standard non-web SDK:
<Project Sdk="Microsoft.NET.Sdk">...</Project>
As far as I can tell, the Web SDK imports additional tasks to allow design-time processing of Web resources, such as Razor views. Change the SDK in your plugin library to Web.
Another parameter of a "Web" project is that it outputs an EXE by default, so also add this to your plugin csproj:
<PropertyGroup>
<OutputType>Library</OutputType>
</PropertyGroup>

Need to serve both GSPs and JSON from a Grails 3.1.5 app

I wanted my Grails 3.1.5 app to serve both JSON data using the *.gson format AND, for some pages/URLs I wanted to continue to use GSPs.
I built an app using the rest-api profile.
Then I copied over controllers and views from an other app that I'd built using the web-api.
In doing so, and to be consistent, I also moved index.gson to a different location.
Now I get a:
Could not resolve view with name 'index' in servlet with name 'grailsDispatcherServlet'
Started digging into the viewResolvers that are available in the 3.1.5 code base. It is possible that the rest-api profile configures a viewResolver to look for *.gson files in a certain location.
Is there anyway to configure maybe a CompositeViewResolver that looks for both the views, *.gson and *.gsps?
If so, how can I do this?
Thanks!
I've managed to resolve this issue by adding this plugin to build.gradle:
compile 'org.grails:grails-plugin-gsp'
and with both
profile 'org.grails.profiles:web'
profile 'org.grails.profiles:rest-api'
and apply plugins
apply plugin: 'org.grails.grails-web'
apply plugin: 'org.grails.grails-gsp'
apply plugin: 'org.grails.plugins.views-json'
Apparently, they remove it when you're using REST profile, to reduce overhead, as you rarely render HTML on REST service side.

Unable to access javascript file (.js) using Service Stack Razor

I'm using Service Stack Razor (ServiceStack.Razor.3.9.45) and I can't access any js nor css file.
Server Error in '/' Application.
This type of page is not served.
Description: The type of page you have requested is not served because it has been explicitly forbidden. The extension '.js' may be incorrect. Please review the URL below and make sure that it is spelled correctly.
Requested URL: /scripts/bootstrap.js
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18044
Any help welcome
[Edit] I have the same problem with the RazorRockStar WebHost application.
This should now be resolved in the latest ServiceStack v3.9.46+ release.
Maybe it helps to someone:
Something similar happened to me. In my case i was working with a compiled views application.
After lot of proofs the problem was that js files (and css, etc) has to be marked as "Embedded Resource".

Display remote content - Joomla

I have a spring MVC app and a joomla "showcase web site".
How can I display data from spring MVC in my joomla showcase site?
My first attempt was to create a simple joomla module with inside jqgrid. But I discovered that many browser deny JSON cross domain and that this attempt is not good.
I also tried with an IFrame.. but I don't like this approach..
The current attempt is to export data from MVC app in RSS. I've installed an rss module in joomla and it works. But it's limited in search and sorting operation.
It would be great to find a way that permit to filter and sort data using some existent and open joomla module.
Does anyone have suggestion on proper export data tecnology and a related module?
#mserioli
You should use the php curl, and in your module you make the request using the GET or POST method to retrieve data (json/xml) from your MVC app