Error while running my MVC application

Asked

Viewed 12,809 times

3

That is the mistake:

Linha 1:  
<%@ Application Codebehind="Global.asax.cs" Inherits="Util.MvcApplication" Language="C#" %>

I had created another project called Util and started to give this problem. What I did, I removed the project and continues. But in my Global.asax it’s like this now:

<%@ Application Codebehind="Global.asax.cs" Inherits="Ruptura.MvcApplication" Language="C#" %>

How do I fix it? That’s the whole mistake:

Erro de Servidor no Aplicativo '/'.
Erro do Analisador
Descrição: Erro ao analisar um recurso necessário para atender esta solicitação.
Examine os detalhes específicos do erro de análise e modifique o arquivo de origem 
apropriadamente.     
Mensagem de Erro do Analisador: Não foi possível carregar o tipo 'Util.MvcApplication'.    
Erro de Origem:
    Linha 1:
    <%@ Application Codebehind="Global.asax.cs" Inherits="Util.MvcApplication" Language="C#" %>
Arquivo de Origem: /global.asax Linha: 1
Informações sobre a Versão: Microsoft .NET Framework Versão:4.0.30319;
    Versão do ASP.NET:4.0.30319.34009

It’s the whole project, but put mine View and the Master hers,

View:

@{
    ViewBag.Title = "Acao";
    Layout = "~/Views/Shared/_LayoutBase.cshtml";
}
<h2>Acao</h2>   
<div class="row">
    <div class="col-md-6">
        <div class="col-md-1">
            <label for="txtCnpjPdv">UF:</label>
        </div>
        <div class="col-md-6">
            <input type="text" class="form-control col-md-6" id="txtCnpjPdv" 
                placeholder="Digite o Cnpj" />
        </div>
    </div>
</div>

And her layout(Master):

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
    @Styles.Render("~/bundles/css")
    @Scripts.Render("~/bundles/modernizr")
    @Scripts.Render("~/Scripts/Util.js")
</head>
<body>
    <div class="navbar navbar-inverse navbar-fixed-top">
        <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" 
                    data-target=".navbar-collapse">
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                @*@Html.ActionLink("Pedidos", "Index", "Home", null, new { 
                  @class = "navbar-brand" })*@
            </div>
            <div class="navbar-collapse collapse">
                <ul class="nav navbar-nav">
                </ul>
            </div>
        </div>
    </div>
    <div class="container body-content">
        @RenderBody()
        <hr />
        <footer>
            <p>&copy; @DateTime.Now.Year - Laboratórios Ltda</p>
        </footer>
    </div>
    @Scripts.Render("~/bundles/jquery")
    @Scripts.Render("~/bundles/bootstrap")
    @RenderSection("scripts", required: false)
</body>
</html>

Got worse!
I saw that the project Useful was in the path and I deleted it for good and now there’s an error. It seems to me that somewhere in iisexpress it’s being requested and there’s nothing else of it, from Useful:

HTTP Error 500.19 - Internal Server Error
A página solicitada não pode ser acessada porque os dados de configuração 
relacionados à página são inválidos.

Informações detalhadas do erro:
Módulo             IIS Web Core
Notificação        Desconhecido
Manipulador        Ainda não determinado
Código do erro     0x80070003
Erro de Configuração       Não é possível ler o arquivo de configuração
Arquivo de Configuração    \\?\D:\Projetos ACHÉ\Ruptura\Util\web.config
URL solicitada             http://localhost:53130/
Caminho físico
Método de logon    Ainda não determinado
Usuário de logon   Ainda não determinado
Diretório de Rastreamento de Solicitação: 
    C:\Users\Paulo\Documents\IISExpress\TraceLogFiles\
Origem da Configuração:
   -1: 
    0: 

More information:

This error occurs when there is a problem reading the Web server or Web application configuration file. In some cases, event logs may contain more information about the cause of this error.

If you see the text "There is a section 'system.web.extensions/scripting/scriptResourceHandler' defined duplicate", this error happened because you are running an application based on the .NET Framework 3.5 in the .NET Framework 4. If you are running the Webmatrix, to resolve this issue, go to the Settings node to set the version of .NET Framework as ". NET 2". It is also possible to remove the extra sections from the web.config file.

  • Posts the header of your code c# (codebehind)

  • I gave a Find across the entire Solution and did not find this line: <%@ Application Codebehind="Global.asax.Cs" Inherits="Util.Mvcapplication" Language="C#" %>. Where could that line be for me to fix?

  • So this line usually sits at the top of the Asp.net document before the doctype. What did you do when you created the new project? Did you copy and paste code? You probably pulled information with the namespace of the other project and so it is looking for a file that it cannot find.

  • Before Doctype I have nothing in any of my views.

3 answers

1

I had the same problem. The extension file "csproj" ("Filename.csproj") was not creating the references for the new screens.

Then, I restarted the PC, in order to be able to stop all runs of open programs, I opened the file. csproj, and created the reference manually in the file and saved, as the IDE itself does.

EXAMPLE:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  ...

 <Content Include="NomePastaDoArquivo\NomeDoArquivo.aspx" />

  ...

 <Compile Include="NomePastaDoArquivo\NomeDoArquivo.aspx.cs">
      <DependentUpon>NomeDoArquivo.aspx</DependentUpon>
      <SubType>ASPXCodeBehind</SubType>
    </Compile>
    <Compile Include="NomePastaDoArquivo\NomeDoArquivo.aspx.designer.cs">
      <DependentUpon>NomeDoArquivo.aspx</DependentUpon>
    </Compile>

1

By the way ai, your example shows that you are assigning a namespace to "Inherits" and you should assign the Class that is within Global.asax.Cs

take my example:

in Global.asax

<%@ Application Codebehind="Global.asax.cs" Inherits="MyMvcApplication.MvcApplication" Language="C#" %>

in Global.asax.Cs

namespace MyMvcApplication{
    public class MvcApplication : System.Web.HttpApplication {...}
}

0

It is very simple to solve this problem: you need to rename the field Inherits, because he is trying to inherit from a class that does not exist or that has been renamed the namespace, or that this DLL is missing from your project:

<%@ Application Codebehind="Global.asax.cs" Inherits="Ruptura.MvcApplication" Language="C#" %>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.