SignalR not mapped in startup class - asp.net-mvc

I have installed signalr in my project and registered it in startup class like this
public void Configuration(IAppBuilder app)
{
app.MapSignalR();
}
but I have an error in browser console
Uncaught Error: SignalR: Error loading hubs. Ensure your hubs reference is
correct, e.g. <script src='/signalr/js'></script>.
at Object.start (jquery.signalr-2.2.2.min.js:9)
at notificationsmodule.js:2
I added this scripts to layout page
<script src="~/Scripts/jquery.signalR-2.2.2.min.js"></script>
<script src="~/signalr/js"></script>
<script src="~/Content/Notification/NotificationsModule.js"></script>
I have searched about this error and I find some solution that doesn't fix my problem like:
add this tags to web.config file
<appSettings>
<add key="owin:AutomaticAppStartup" value="true"/>
<add key="owin:appStartup" value="Moadi.Web.Startup"/>
<appSettings/>
but when I do this the .NET Framework app fails with "Could not load file or assembly 'netstandard, Version=2.0.0.0'"
Can anyone help me solving this issue

I have solved it myself
Since OWIN was not configured in the creation of project. I manually deleted bin folder from project folder.

Related

Castle Windsor issue with NUnit testing - Instance not initialize properly

In MVC application we are using windsor container and NUnit testing.
Following is the windsor registration code:
public void Install(IWindsorContainer container, IConfigurationStore store)
{
container.Register(Component.For<HttpContextBase>().LifeStyle.PerWebRequest.UsingFactoryMethod(() => new HttpContextWrapper(HttpContext.Current)));
container.Register(Component.For<IHttpContextBaseWrapper>().ImplementedBy<HttpContextBaseWrapper>().LifestylePerWebRequest());
container.Register(Component.For<IWebUtility>().ImplementedBy<WebUtility>().LifestylePerWebRequest());
container.Register(Component.For<IExceptionReporter>().ImplementedBy<ExceptionReporter>().LifestylePerWebRequest());
container.Register(Component.For<ICacheProvider>().ImplementedBy<WebCacheProvider>().LifestylePerWebRequest());
container.Register(Component.For<IEmailNotifier>().ImplementedBy<EmailNotifier>().LifestylePerWebRequest());
container.Register(Component.For<IUserStore<ApplicationUser>>().ImplementedBy<ApplicationUserStore<ApplicationUser>>().LifestylePerWebRequest());
container.Register(Component.For<ApplicationUserManager>().ImplementedBy<ApplicationUserManager>().LifestylePerWebRequest());
}
It works fine with normal web request(from browser) but not working wile calling controller methods from NUnit test cases. It gives following error while resolving service instances.
Looks like you forgot to register the http module Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule
To fix this add
<add name="PerRequestLifestyle" type="Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule, Castle.Windsor" />
to the <httpModules> section on your web.config.
If you plan running on IIS in Integrated Pipeline mode, you also need to add the module to the <modules> section under <system.webServer>.
Alternatively make sure you have Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 assembly in your GAC (it is installed by ASP.NET MVC3 or WebMatrix) and Windsor will be able to register the module automatically without having to add anything to the config file.
i tried putting
<add name="PerRequestLifestyle" type="Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule, Castle.Windsor" />
in app.config/web.config. But found same error.

Asp.net MVC .properties file is not loading from View(cshtml)

I am doing an asp.net mvc project.In the view(cshtml) page, I have to load several external resources with several extensions.All the resources with extensions .css,.js are loading.But, I have a file has the extension .properties which is not being loaded in same process.I don't know how to solve it.
The error is -
Failed to load resource: the server responded with a status of 404 (Not Found)
My project structure
-Project
-Areas
-Two
-Library
-pdfjs-1.5.188-dist
-web
-locale
-locale.properties
I am using following line to load locale.properties file i the view -
<link rel="resource" type="application/l10n" href="~/Areas/Two/Library/pdfjs-1.5.188-dist/web/locale/locale.properties">
The given path is 100% correct.But, on that path resource is not being found.
Can anybody say me what is the problem and how can I solve this???
You have to add the .properties file extension to your web.config file:
<system.webServer>
<staticContent>
<remove fileExtension=".properties" />
<mimeMap fileExtension=".properties" mimeType="text/plain" />
</staticContent>
</system.webServer>

Graphics missing when deploying to azure

I just deployed my first MVC5 application to azure, and got everything to work, except that it is not showing graphics. On my development machine this works.
My graphics are in a folder ~/Content/Graphics, and this is the part of the _Layout.cshtml that references one,
<img src="#Url.Content("~/content/graphics/EluciusSoft_Logo.svg")" style="height:50px">
I know that the files are on the server, though, since I checked it with WebMatrix. Why are they not displaying?
EDIT: The browser console error message is the following:
Failed to load resource: the server responded with a status of 404
(Not Found)
Here is a screenshot of the site directory using WebMatrix.
If the webserver hasn't been configured with the MIME type for SVG, then it will return a 404 error when you try and access it. You can define the MIME type in your application's web.config:
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
</staticContent>
</system.webServer>
</configuration>

Elmah.MVC working under IIS Express but not IIS 7.5

I'm trying to get Elmah working under ASP.NET MVC and I thought I had.
I used the very convenient Elmah MVC project which automatically setup my web.config file.
Now if I run the project under IIS Express then Elmah works just perfectly.
I can access it with the correct Authorisation and the logs are stored in my SQL Database.
However when I try and run it under IIS 7.5 I get an:
An HTTP 500.19 Internal Server error
Module IIS Web Core
Notification BeginRequest
Handler Not yet determined
Error Code 0x800700b7
Config Error Cannot add duplicate collection entry of type 'add' with unique key attribute 'name' set to 'ErrorLog'
Config File web.config
Config Source:
111: <modules>
112: <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
113: </modules>
I'm baffled as to why this might be. As a test I've created a brand new clean MVC project and it reacts exactly the same way.
do a
<remove name="ErrorLog"/>
before the
<add />
to get rid of any default defined entries named ErrorLog in the modules section of your web.config file.

How to bind to an assembly outside the /bin folder

I have a web-site named CCESD set up in IIS7; my application root folder is D:\Websites\CCESD\CCESD. I also have a folder holding third-party assemblies (not all of which are strong-named) at D:\Websites\CCESD\CCESD\BinCommon: this is because I also have many other web applications under this root site in IIS that will share the DLLs, some of which are unmanaged code and so can't go in the GAC. My web.config file looks like this:
<compilation defaultLanguage="c#" debug="true" targetFramework="4.0">
<assemblies>
...
<add assembly="Telerik.Web.UI, Version=2012.1.288.40, Culture=neutral, PublicKeyToken=121FAE78165BA3D4" />
</assemblies>
</compilation>
...
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="BinCommon" />
</assemblyBinding>
</runtime>
However, when I try to run the web application, I get the following error (after enabling assembly-binding error logging):
Parser Error Message: Could not load file or assembly 'Telerik.Web.UI,
Version=2012.1.288.40, Culture=neutral,
PublicKeyToken=121fae78165ba3d4' or one of its dependencies. The
system cannot find the file specified.
Source File: D:\Websites\CCESD\CCESD\web.config Line: 144
Assembly Load Trace: The following information can be helpful to
determine why the assembly 'Telerik.Web.UI, Version=2012.1.288.40,
Culture=neutral, PublicKeyToken=121fae78165ba3d4' could not be loaded.
Assembly manager loaded from:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable c:\windows\system32\inetsrv\w3wp.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: User = IIS APPPOOL\CCESD
LOG: DisplayName = Telerik.Web.UI, Version=2012.1.288.40, Culture=neutral,PublicKeyToken=121fae78165ba3d4 (Fully-specified)
LOG: Appbase = file:///D:/Websites/CCESD/CCESD/
LOG: Initial PrivatePath = D:\Websites\CCESD\CCESD\bin Calling
assembly : (Unknown). ===
LOG: This bind starts in default load context.
LOG: Using application configuration file:
D:\Websites\CCESD\CCESD\web.configLOG: Using host configuration file:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config
LOG: Using machine configuration file from
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Telerik.Web.UI, Version=2012.1.288.40,
Culture=neutral, PublicKeyToken=121fae78165ba3d4
LOG: Attempting download of new URL
file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary
ASP.NET Files/root/e11e9098/9e133b72/Telerik.Web.UI.DLL.
LOG: Attempting download of new URL
file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary
ASP.NET
Files/root/e11e9098/9e133b72/Telerik.Web.UI/Telerik.Web.UI.DLL.
LOG: Attempting download of new URL
file:///D:/Websites/CCESD/CCESD/bin/Telerik.Web.UI.DLL.
LOG: Attempting download of new URL
file:///D:/Websites/CCESD/CCESD/bin/Telerik.Web.UI/Telerik.Web.UI.DLL.
LOG: Attempting download of new URL
file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary
ASP.NET Files/root/e11e9098/9e133b72/Telerik.Web.UI.EXE.
LOG: Attempting download of new URL
file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary
ASP.NET
Files/root/e11e9098/9e133b72/Telerik.Web.UI/Telerik.Web.UI.EXE.
LOG: Attempting download of new URL
file:///D:/Websites/CCESD/CCESD/bin/Telerik.Web.UI.EXE.
LOG: Attempting download of new URL
file:///D:/Websites/CCESD/CCESD/bin/Telerik.Web.UI/Telerik.Web.UI.EXE.
I have checked that the file exists and the version and public-key information are correct. What am I doing wrong?
I found it eventually; in the end, it was down to this:
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
My project began life in Visual Studio 2005; hence the xmlns attribute shown above was present in the containing element of my web.config file. Removing it fixed the problem and now my assemblies are being loaded correctly.
Googling reveals that the xmlns attribute is there to enable intellisense in Visual Studio (which indeed it does): it says nothing about having any effect on loading assemblies, so this is all a little strange (not to mention annoying). Still, now it's working.

Resources