When I try to access a website that I built using MVC, I am met with error 500. I contacted my hosting providers and they said the issue was with my web.config file. Problem with that is there wasn't one in the project when I created it through Visual Studio.
I followed this guide to add one: How to: Create Web.config Files. Which is provided by Microsoft.
I'm at a complete loss here as I don't know what sort of info is needed or how to configure it so that it will work.
These are the current contents of the file:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!-- To customize the asp.net core module uncomment and edit the following section.
For more info see https://go.microsoft.com/fwlink/?linkid=838655 -->
<!--
<system.webServer>
<handlers>
<remove name="aspNetCore"/>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
</handlers>
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
</system.webServer>
-->
</configuration>
What I'm asking for is a bit of direction as to what I need to do, and why this wasn't included in the website to begin with.
You need to clarify with your provider do they support asp.net core since it has its own runtime library.
Also web.config is related to classical ASP.NET framework not for ASP.NET Core.
Try to create app with any .NET version 4.x in visual studio. Within template you’ll see web.config.
If you still want to use .net core it uses slightly different config mechanisms. You can read more about in www.asp.net tutorial section of asp.net core
Related
How can I update a regular VC++ project into a CUDA runtime project in Visual Studio 2019?
I tried to add the CUDA markups of the vcxproj project file, without success.
I'm expecting to see the CUDA/C++ tree in project properties.
In <Project DefaultTargets="Build" there should be:
<PropertyGroup>
<CUDAPropsPath Condition="'$(CUDAPropsPath)'==''">
$(VCTargetsPath)\BuildCustomizations</CUDAPropsPath>
</PropertyGroup>
it defines the variable CUDAPropsPath used further.
In the same <Project :
<ImportGroup Label="ExtensionSettings">
<Import Project="$(CUDAPropsPath)\CUDA 10.1.props" />
</ImportGroup>
add the default parameters of CUDA/C++ and CUDA/linker in project properties.
For all the .cu files, we need in <ItemGroup> with the other cpp files:
<CudaCompile Include="MyKernel0.cu"/>
And in <ImportGroup Label="ExtensionTargets"> there must be:
<Import Project="$(CUDAPropsPath)\CUDA 10.1.targets" />
that adds the CUDA/C++ and CUDA/linker in project properties.
I am trying to add a JSON endpoint to a WCF RIA Service.
I have read many tutorials on this and I have also watched videos on silverlight.net.
Everywhere I find something on this topic, I am told to use the domainService Tag in web.config.
One code example looks like this:
<system.serviceModel>
<domainServices>
<endpoints>
<add name="JSON" type="Microsoft.ServiceModel.DomainServices.Hosting.JsonEndpointFactory, Microsoft.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</endpoints>
</domainServices>
<system.serviceModel>
This is not working and there are two issues:
In Visual Studio 2010 the domainService Tag is underlined blue, with the hint, that this is an unexpected tag.
In IIS the domainService Tag is producing an unknown element error.
Among others, I have referenced the following DLLs in my web project:
-Microsoft.ServiceModel.DomainServices.Hosting
-Microsoft.ServiceModel.DomainServices.Tools
-Microsoft.ServiceModel.DomainServices.LinqToSql
-System.ServiceModel.DomainServices.EntityFramework
-System.ServiceModel.DomainServices.Hosting
-System.ServiceModel.DomainServices.Hosting.OData
-System.ServiceModel.DomainServices.Server
I also have the WCF RIA Services V1.0 SP2 installed.
I really don't know, how to resolve it. I need help. I have googled and searched excessively.
Thank you.
This case is solved. Please read my comments to Jeff's answer. You may find some additional information on this problem.
The JSON endpoint is part of the WCF RIA Services Toolkit, not the product itself. You can get the Toolkit MSI here:
http://www.microsoft.com/en-us/download/details.aspx?id=26939
However, I recommend pulling the JSON endpoint in through NuGet instead, using the RIAServices.Endpoints package:
http://nuget.org/packages/RIAServices.Endpoints
Here's some more information about the NuGet packages available:
http://jeffhandley.com/archive/2012/12/10/RIA-Services-NuGet-Package-Updates-ndash-Including-Support-for-EntityFramework.aspx
For me the correct way to resolve the issue was adding the following to web.config
<configuration>
<configSections>
<sectionGroup name="system.serviceModel">
<section name="domainServices" type="System.ServiceModel.DomainServices.Hosting.DomainServicesSection, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" allowDefinition="MachineToApplication" requirePermission="false" />
</sectionGroup>
</configSections> ...
I'm working with Tridion 2011 SP1 and Razor templating but have an issue with creating pages and inserting content through the User Interface 2012. It appears when I try this that my Razor helpers, namespaces and assemblies listed in the Tridion.ContentManager.config file don't get included.
I tried adding the references to the helpers directly in the razor templates and everything works fine but I would prefer to not have to do this in every Razor Template.
When I try creating a page through the UI I get the following Razor error:
TemplateCompileException: CS0103: The name 'GetBreadcrumbStatus' does not exist
in the current context Line 64 Column 21: if(GetBreadcrumbStatus())
My Tridion.ContentManager.config file contains the following for the Razor Mediator:
<razor.mediator cacheTime="600" extractBinaries="true">
<namespaces>
<add namespace="Tridion.Extensions.Mediators.Razor.Models" />
<add namespace="System.Linq" />
</namespaces>
<imports>
<add import="C:\Program Files (x86)\Tridion\Razor Mediator\Helpers\GeneralHelper.cshtml" />
</imports>
</razor.mediator>
Any ideas as to why the UI doesn't include the helpers and namespaces unless there referenced directly in the Razor templates?
Thanks in advance.
Some background on the Session Preview mechanism
The new UI uses a special type of publisher for its Session Preview mechanism, which optimizes the publishing process to get the "near real time" behavior that people expect in such an environment. The optimized publisher accomplishes this by skipping certain steps, one of which is reducing the resolving process (so fewer items get publishes) and not invoking custom resolvers.
On your problem
Are your Razor templates invoked at all when you create the new page?
So, appSettings can be set in app.config, web.config, machine,config... But, when you work under IIS 7 you can also have appSettings being applied under applicationHost.config with a specific carve out for your site. So, what's a consistent way for me to know what AppSettings I should be using???
System.Configuration.ConfigurationManager is fine if this is a client profile.
System.Web.Configuration.WebConfigurationManager if this is a web-app ... well, maybe.
Microsoft.Web.Administration if I expect values in applicationHosting.config - ouch ... and even then they don't roll-up hierarchically so it seems that you're left holding that process.
Does anyone have a consistent approach to processing AppSettings that accounts for applicationHost.config?
You can't actually specify <appSettings> in your applicationHost.config file. This is because applicationHost.config defines settings specific to IIS only. You can review the applicationHost.config schema to confirm this:
%systemroot%\System32\inetsrv\config\schema\IIS_schema.xml
If you try to edit applicationHost.config and add an <appSetting> section to a site or under a <location path="..."> section you will get an error (IIS may not start and IIS MMC console will display a configuration error).
If you configure a global application setting in IIS manager this actually gets configured in the master web.config file that matches the default .NET Framework version setting in IIS.
<appSettings/> is specific to the .NET Framework and can only be configured in:
%SYSTEMROOT%\Microsoft.NET\Framework\[framework version]\CONFIG\machine.config
%SYSTEMROOT%\Microsoft.NET\Framework\[framework version]\CONFIG\web.config
%SYSTEMROOT%\Microsoft.NET\Framework64\[framework version]\CONFIG\machine.config
%SYSTEMROOT%\Microsoft.NET\Framework64\[framework version]\CONFIG\web.config
and of course your application's app.config or web.config files.
My advice would be to keep these settings local to your application unless there is the rare occasion where you need some value to be available globally.
Update:
Now that I understand your problem - you have multiple IIS sites which all point to the same physical folder - there is a way to approach this.
You could have a configuration table in your database that has a primary key of whatever the HTTP_HOST value is. This maps to a prefix, for example:
Host SitePrefix
==== ======
domain1.com D001
domain2.com D002
In your web.config:
In your application's Application_Start event in Global.asax.cs initialise an application wide value:
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
string httpHost = HttpContext.Current.Request.ServerVariables["HTTP_HOST"];
Application["SitePrefix"] = GetSiteKeyFromDb(httpHost);
}
This value will be available across the whole application but unique to the site.
When you need to read a setting that is specific to the site:
string siteSetting = ConfigurationManager.AppSettings[
HttpContext.Current.Application["SitePrefix"] + "_Setting1"
];
But if you're hitting the database in Application_Start then it may actually be expedient to store all these site specific settings in the database then read and cache them in Application instead of using <appSettings />.
I used the information provided by Anti-Santa's answer to accomplish this but I didn't want to parse the URL and have another database to look up information. The same codebase is used on-premise and I wouldn't have those pieces in that scenario.
Just add the appSettings to the .NET Framework web.config with a location node.
In %SYSTEMROOT%\Microsoft.NET\Framework64\[framework version]\Config\web.config, add the following where Site1 and Site2 are my two applications pointing to the same physical directory:
<?xml version="1.0" encoding="utf-8"?>
<!-- the root web configuration file -->
<configuration>
<!-- App settings for the different applications -->
<location path="Default Web Site/Site1">
<appSettings>
<add key="ConnectionString" value="the cnn str"/>
</appSettings>
</location>
<location path="Default Web Site/Site2">
<appSettings>
<add key="ConnectionString" value="the cnn str"/>
</appSettings>
</location>
...
</configuration>
The web.config in the physical folder will override this appSetting so I also needed to remove it from that file.
I created an ASP.NET MVC 2 project with a model. I then created a view and selected for it to be strongly-typed for the model that was created. I also did the same thing with a partial view. In either case for some reason I am getting the error: "Cannot resolve symbol 'Html' whenever I try to use the Html helper methods that ASP.NET MVC 2 provides for creating form elements for the model. I have Visual Studio 2010 and ASP.NET MVC 2 installed. Is this something that has been seen before? If so, is there a solution that will resolve this?
My model looks like:
public namespace MyNamespace { public class MyModel { public string MyProperty { get; set; } } }
The first line of my regular view is:
<%# Page Language="C#" Inherits="System.Web.Mvc.ViewPage<MyNamespace.MyModel>" %>
The first line of my partial view is:
<%# Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<MyNamespace.MyModel>" %>
I think I found a fix for your problem (I'm not sure if it's temporary though)
When you create a new asp mvc project it contains 2 web.config files. One on the project root and one on the Views directory.
I thought that the one on the Views wasn't required so I excluded it. The next day resharper stop recognizing the Html helper methods. I added it again and reload the solution and all errors were gone.
Hope this helps
EDIT
this link would probably help with this problem
I get this error all the time, I don't quite know what causes it. It must have something to do with Visual Studio failing to parse the Page / UserControl directive properly and subsequently not loading the correct type defined in the inherits attribute.
It doesn't really affect the application other than losing intellisense and you also get a lot of errors in the visual studio output when you have the aspx view file open and build your solution (your solution should still build no worries).
I can get the error to go away every now and again by messing with the Page / UserControl directive, which forces Visual Studio to re-parse it. E.g. put a random space anywhere inside the inherits attribute and then delete it.
HTHs,
Charles
Ps. I too am using resharper, but I'm not sure if it's to blame.
Yea, this has happened a couple times to me as well. If the application loads correctly and the view loads the objects I suspect it might be your ReSharper Build. Try updating your version of Resharper and see if it recognizes your models.
I've had the same issue, also removed the web.config in a moment of ignorance...
Merging the below piece of the web.config to your web.config in the root of the web application will do the trick also. It's works again like it should and still you have only one web.config file.
<system.web>
<pages
validateRequest="false"
pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
</namespaces>
<controls>
<add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
</controls>
</pages>
</system.web>
This error happened to me because I moved by mistake the web.config that was inside the "Views" folder.
This file contains the include of System.Web.Mvc. Hope this helps.
Greetings