How to route URL from classic asp to MVC application - asp.net-mvc-4

I have an existing asp application which is running from a long time and many clients used to post the from Form Post or Ajax post with different technologies (e.g. .Php, .Asp, .Aspx). now we are planning to upgrade the asp application to MVC5. As URL’s are modified and existing URL’s are not available they are getting 404 error.
Can anyone know how to route the URL from asp to MVC. Below is my example
http://bbbbbb.com/test/test/mytest.asp
to
http://newsite.com/mycontoller/myaction

This may not be the answer you are looking for, but we use permanent redirection. Just replace the code in http://bbbbbb.com/test/test/mytest.asp with:
<%
Response.Status = "301 Moved Permanently"
Response.AddHeader "Location", "http://newsite.com/mycontoller/myaction"
%>

Related

Why does .net core Blazor HttpClient.PostAsJsonAsync get a 400 bad request with ValidateAntiForgeryRequestToken

I am working on a Blazor Server project, and I am doing a POST using HttpClient.PostAsJsonAsync in a Razor page. The anti forgery request token seems to have some difficulties. When I put the directive [ValidateAntiForgeryToken] with the Post action, it fails with a 400 Bad Request. I’m getting a 200 Success when the directive is not present.
This is not consistent with the documentation I’ve read on .net core. See the following URL
It contains the following statement:
Razor Pages are automatically protected from XSRF/CSRF. For more
information, see XSRF/CSRF and Razor Pages.
Why is the post failing with [ValidateAntiForgeryToken]? I appreciate any words of wisdom on this.

Bug or misconfigured? ASP.NET Core 2.1 firing 404 error on Access Denied

I am not sure if I found a bug, or if I just messed up the configuration some how.
I have an ASP.NET Core 2.1 Razor website using AzureADB2C authentication, utilizing the new 'pre-packaged' configuration utilities). When I try to access a page that my test user doesn't have access to, it returns a generic 404 page instead of going to the pre-defined AccessDenied page.
Looking at the browser URL, it is trying to go to:
https://localhost:44310/Account/AccessDenied?ReturnUrl=%2FAbout
But I think it should be:
https://localhost:44310/AzureADB2C/Account/AccessDenied?ReturnUrl=%2FAbout
(Note: if I manually put this in the browser, it works correctly)
When, you sign out, it takes you to:
https://localhost:44310/AzureADB2C/Account/SignedOut
Does anyone know if there is a configuration to control this redirect? Or is this a bug in the new 2.1 Authentication modules? (And if so, any ideas how to work around it until it is fixed?)
I reported this to MSFT as a bug and they are looking into it. But I did figure out a workaround, in case anyone else is getting this same issue.
The issue on MSFT site is: https://developercommunity.visualstudio.com/content/problem/301357/microsoftaspnetcoreauthenticationazureadb2cui-acce.html
The workaround is to use the Rewrite Middleware to redirect the call. Putting the below into the Configure method of your Startup.cs class will handle the issue.
// Workaround for AccessDenied URL error in MSFT code
RewriteOptions rewrite = new RewriteOptions().AddRedirect("^Account/AccessDenied(.*)", "AzureADB2C/Account/AccessDenied$1");
app.UseRewriter(rewrite);

Dots in URL causes 404 with Web API call in .net core

I have a similar requirement which is mentioned in the link Dots in URL causes 404 with ASP.NET mvc and IIS . Our requirement is, we also do have URLs with dots in the path. For example I may have a URL such as www.example.com/people/michael.phelps (This example is taken from above link)
URLs with the dot generate a 404. If we pass without the dot, then everything works. If we add the dot I get a 404 error.
The above link provide solution for earlier versions of .net where we can have webconfig files. But we are using .net core to build web API application. Dotnet core does not support webconfig files. Can someone please suggest how can we arrive at the solution by using .net core.
Late answer but we had a similar case:
We had a url looking like https:/domain.com/somepath/smoething.cd
This returned a 404 from the IIS. Adding a / at the end of the url behind the .cd fixed the issue.
Strange but notable: not all.something return a 404, .com at the end of the path for example works

How to call ASP MVC CSHTML View directly with ".cshtml" extension from browser

I want to call my asp mvc CSHTML View directly from browser with ".cshtml" extension like:
www.mysite.com\receive.cshtml?...
instead
www.mysite.com\receive?...
but i got 404
any idea ?
1. By default IIS Request Filtering is configured not to serve requests to .cshtml files.
2. Razor views are not meant to be accessed directly by the client. yet, take a look at https://github.com/ServiceStack/RazorRockstars

Sitefinity 4.4 and Extensionless URLS: Is the sf404.aspx error mapping still required

Does anyone know if you still need the sf404.aspx mapping for Sitefinity 4.4?
I'm trying to run a new test SF 4.4 project, but when I try and login the page just gives me the following:
HTTP 404 cannot find /sf404.aspx (this was mapped like that for Sitefinity 3.7)
I then changed the IIS 404 configuration from sf404 to default and now I just get HTTP/1.1 404 Object Not Found.
The project works through Cassini, but not through IIS 6.
Any ideas?
Regards,
Jacques
the sf404.aspx page is definitely only used for Sitefinity 3.x and should not be mapped in a Sitefinty 4 website.
If you are attempting to run a newer version of Sitefinity on IIS6, you need to make sure to use a wildcard mapping so that all requests go through the ASP.NET engine.
This page details everything you need to setup to run Sitefinity on IIS6: http://www.sitefinity.com/documentation/documentationarticles/installation-and-administration-guide/install-sitefinity/configuring-the-iis-to-host-sitefinity-projects
You might also find this blog post helpful: http://www.sitefinity.com/blogs/joshmorales/posts/11-02-23/installing_sitefinity_4_on_iis_6.aspx