I have deployed an web app to Azure server but when I open my website it gives me error
The page cannot be displayed because an internal server error has occurred.
In browser console the error are
Failed to load resource: the server responded with a status of 500 (URL Rewrite Module Error.)
aspapireact.azurewebsites.net/:1
Failed to load resource: the server responded with a status of 500 (URL Rewrite Module Error.)
I did all the changes required to deploy app on Azure like
connection string in appsettings,
API url in all pages,
Allow access to other resource for Azure SQL DB
connection string in configuration in Azure app service setting
Now I don't know what to do and where should I do changes
this is link for my project on git
https://github.com/rlbrs/ASPAPIReact
this one has all localhost connection but in Azure I have made required changes
Connection string - tcp:aspapireact.database.windows.net,1433;Initial Catalog=ReactTask;Persist Security Info=False;User ID=rlbrs;Password=*****;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;
API URL - https://aspapireact.azurewebsites.net/api/Customers
It say URL module error do I have to make changes in my DB Context.cs file
namespace RahulTask1.Model
{
public class DatabaseContext: DbContext
{
public DatabaseContext(DbContextOptions<DatabaseContext> options) : base(options) { }
public DbSet<Customer> Customer { get; set; }
public DbSet<Sale> Sales { get; set; }
public DbSet<Product> Product { get; set; }
public DbSet<Store> Store { get; set; }
}
}
Web Config file from azure/server
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*"
modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath=".\RahulTask1.exe"
stdoutLogEnabled="false" stdoutLogFile="\\?
\%home%\LogFiles\stdout" hostingModel="inprocess" />
</system.webServer>
</location>
</configuration>
Related
I am trying to bring up a application written in ASP.NET CORE 2.1 and Angular 7.
I am using IIS in Windows Server 2016 and installed .NET Core 2.1 Runtime & Hosting Bundle for Windows.
After publishing the solution in Visual Studio 2017, web.config has this content:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\Diarias.Web.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" />
</system.webServer>
</location>
</configuration>
<!--ProjectGuid: b3f72ccb-207e-461c-b822-2152a37a2311-->
But after trying to start the website, I get this error:
System.InvalidOperationException: The SPA default page middleware could not return the default page '/index.html' because it was not found, and no other middleware handled the request.
Your application is running in Production mode, so make sure it has been published, or that you have built your SPA manually. Alternatively you may wish to switch to the Development environment.
Program.cs:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
namespace Diarias
{
public class Program
{
public static void Main(string[] args)
{
CreateWebHostBuilder(args).Build().Run();
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>();
}
}
What is wrong?
Asp.Net Core doesn't seem to recognize the user from the call context?.User?.Identity?.Name when windows authentication is enabled and running in IIS Express or IIS.
Desired behavior: Enabling both Windows authentication and anonymous authentication in IIS and/or IIS Express, Asp.Net Core should automatically recognize the windows user.
Actual behavior: When I enable both windows and anonymous authentication in IIS or IIS Express, the user name is null. When I disable anonymous authentication or call HttpContext.ChallengeAsync(IISDefaults.AuthenticationScheme), I get a login prompt, which I don't want.
My understanding is that, even though I want to use this for Active Directory, I don't need active directory or a domain to authenticate a windows user.
Environment:
Windows 8.1 (not on a domain)
IIS 8.5 / Visual Studio 2017 w/ IIS Express
Windows Authentication security feature installed
Windows Authentication & (with NTLM provider) & Anonymous Authentication Enabled
Logged in as local account user
Dependencies:
Microsoft.AspNetCore.All 2.0.8
Startup:
public void ConfigureServices(IServiceCollection services)
{
services.Configure<IISOptions>(iis =>
{
iis.AuthenticationDisplayName = "Windows";
iis.AutomaticAuthentication = true;
});
services.AddAuthentication(IISDefaults.AuthenticationScheme);
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseAuthentication();
app.Run(async (context) =>
{
await context.Response.WriteAsync(JsonConvert.SerializeObject(new
{
UserName = context?.User?.Identity?.Name
}));
});
launchSettings.json:
{
"iisSettings": {
"windowsAuthentication": true,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:51682/",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
web.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<remove name="aspNetCore" />
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore forwardWindowsAuthToken="true" processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" />
</system.webServer>
</configuration>
applicationhost.config: (IIS Express)
Based on this article: https://learn.microsoft.com/en-us/iis/configuration/system.webServer/security/authentication/windowsAuthentication/
<authentication>
<anonymousAuthentication enabled="true" userName="" />
<basicAuthentication enabled="false" />
<clientCertificateMappingAuthentication enabled="false" />
<digestAuthentication enabled="false" />
<iisClientCertificateMappingAuthentication enabled="false"></iisClientCertificateMappingAuthentication>
<windowsAuthentication enabled="true">
<providers>
<add value="NTLM" />
</providers>
</windowsAuthentication>
</authentication>
A couple things:
When you disable anonymous authentication, you get a popup because the browser likely doesn't trust the site. You need to open Internet Options (from the Windows Control Panel) -> Security tab -> Click 'Trusted Sites' -> Click 'Sites' and add the URL to your site there. Both IE and Chrome use those settings for deciding whether to automatically send your credentials.
When you have both anonymous and Windows authentication enabled, anonymous takes precedence except in places where you tell it that the user must be logged in. To do that, use the [Authorize] attribute either on a controller, or just on individual actions. There are more details in the documentation, under the heading Allow Anonymous Access.
Need help with configuring HTTP Proxy while using netMessagingBinding to connect to Service Bus endpoint.
I have an Internet access through the proxy server. When I try to connect to the WCF Service hosted on a worker role on Azure through Service Bus endpoint I get exception that the application cannot connect to the remote endpoint. When I do the same thing through direct internet access everything works perfectly.
Proxy servers can be tricky depending on the type of proxy. Try changing the settings of your web.config/app.config to enable proxy support:
Detect automatically:
<system.net>
<defaultProxy enabled="true" useDefaultCredentials="true" />
</system.net>
Define proxy url:
<system.net>
<defaultProxy enabled="true" useDefaultCredentials="true" />
<proxy autoDetect="True" proxyaddress="http://..."/>
</defaultProxy>
</system.net>
Custom credentials:
<appSettings>
<add key="ProxyUser" value="" />
<add key="ProxyPassword" value="" />
<add key="ProxyDomain" value="" />
<add key="ProxyUrl" value="" />
</appSettings>
<system.net>
<defaultProxy enabled="true">
<module type="CustomProxyCredentials.ProxyBridge, CustomProxyCredentials"/>
</defaultProxy>
</system.net>
namespace CustomProxyCredentials
{
public class ProxyBridge : IWebProxy
{
public ICredentials Credentials
{
get { return new NetworkCredential(ConfigurationManager.AppSettings["ProxyUser"], ConfigurationManager.AppSettings["ProxyPassword"], ConfigurationManager.AppSettings["ProxyDomain"]); }
set { }
}
public Uri GetProxy(Uri destination)
{
return new Uri(ConfigurationManager.AppSettings["ProxyUrl"]);
}
public bool IsBypassed(Uri host)
{
return false;
}
}
}
Connectivity mode:
Microsoft.ServiceBus.ServiceBusEnvironment.SystemConnectivity.Mode = Microsoft.ServiceBus.ConnectivityMode.Http;
Anyways, configuration should be sufficient in order for this to work correctly.
I am not able to work with htpphandlers in azure after deploy, it is ok with in the local machine.
In web.config I declared as follows
<system.web>
<httpHandlers>
<add verb="*" path="*.cspx" type="WebRole1.Handle,WebRole1"/>
</httpHandlers>
In my handler.cs file i written as follows.
namespace WebRole1
{
public class Handle : IHttpHandler
{
#region IHttpHandler Members
bool IHttpHandler.IsReusable
{
get { return true; }
}
void IHttpHandler.ProcessRequest(HttpContext context)
{
context.Server.Transfer("Test.aspx", true);
}
#endregion
}
}
In my local machine it is working fine. But after deploy to windows azure getting
500 internal server error.
I think your problem is related with having custom handlers in system.web instead of system.webserver.
Move your custom HTTP Handler to System.webserver as below:
<system.webserver>
<httpHandlers>
<add verb="*" path="*.cspx" type="WebRole1.Handle,WebRole1"/>
</httpHandlers>
<system.webserver>
I am having trouble configuring my ServiceStack REST service to work on my production IIS 7.5 box. It works fine running localhost, and it also works fine if I deploy in the root of "Default Web Site" - /EmployeeSvc. I have a virtual directory structure under Default Web Site for organizational purposes (note custom path in web.config). I can browse successfully to the default.htm at this location, but when I try to execute the built-in /hello example I receive:
Server Error 404 - File or directory not found.
The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.
Like I said, the built-in /hello example works perfectly from localhost and from a root iis folder under default web site, but not from within a directory structure. What am I doing wrong with the location-path?
Thanks in advance! Here is web.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="Employees-NoAuth/WebServices/EmployeeSvc">
<system.web>
<httpHandlers>
<add path="*" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" />
</httpHandlers>
</system.web>
<!-- Required for IIS 7.0 -->
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<add path="*" name="ServiceStack.Factory" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" preCondition="integratedMode" resourceType="Unspecified" allowPathInfo="true" verb="*" />
</handlers>
</system.webServer>
</location>
<system.web>
<customErrors mode="RemoteOnly"/>
<compilation debug="true" targetFramework="4.0" />
</system.web>
</configuration>
I'd try the following:
1. Remove location node from web.config. Move SS configuration out of it.
2. Register base URL path in your class derived from AppHostBase:
public override void Configure(Container container)
{
this.SetConfig(new EndpointHostConfig { ServiceStackHandlerFactoryPath = "base/path" });
}