SurfaceController file edited by Kudu does not change the application content - asp.net

i have a problem with my application created in umbraco.
I have implemented the application on microsoft azure and I wanted to edit one function in the controller using kudu. I have edited the controller file, but the changes have not been made in the application (as I will go to the site is the state from before editing). I have combined a bit how to get the desired effect, I even deleted the controller file and it is still the same (state from before. Can you write to me how to correctly edit the controller file?

Related

Where is the controller and view for the built-in authentication in ASP.NET?

I am learning ASP.NET coming from a Node.js background.
When I create a new MVC project, I can choose to have built-in register/login.
This gives me the following views, where I can register and login.
But I am confused as I cannot find the corresponding controller or views in the directory, which is problematic if I want to customize the behaviour.
Can someone shed the light on how this works and where are the controller and view? Thanks.
It is not in project folder. UI is loaded from Microsoft.AspNetCore.Identity.UI library.
You can check it's code in below URL. you can understand how to configure by looking at code.
https://github.com/dotnet/aspnetcore/tree/main/src/Identity/UI/src
They are not using MVC style, they are using Razor pages with code behind C# model.
You can provide your own UI by using attribute like [IdentityDefaultUI(typeof(LoginModel<>))] on your page model.
Reference:
https://github.com/dotnet/aspnetcore/blob/main/src/Identity/UI/src/Areas/Identity/Pages/V5/Account/Login.cshtml.cs
The controller folder contains the controller file in which you will see the server side(C#) code it will receive request from view and process on it and send back to view. And views folders contains the html code that get input from user. In this project structure, you will see shared folder that contains generic view files and _loginpartial.cshtml is login view.

Razor Project on with CSHTML files

A project kind of landed on my hands and I am having issues with one thing.
I have an already working project that is installed on a local server. I am able to make changes to existing pages, but I just tried creating a new page from copying an existing page and modifying it, but I keep getting an error when I try to open it. This is the error:
HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
From my research so far, it looks like there has to be a controller in place to properly map the new pages, but I have not been able to find that within the project. I copied the project and opened it with ms visual on a different machine, same issue, everything opens and works just fine except the new page that I added. While the project is open on ms visual I do not see a folder for controllers either.
I would greatly appreciated if someone can point me on the right direction
Thank you,
Cesar R
With Model/View/Controller, you need a Controller to match with the View.
Let's say you add a new folder and cshtml to your file in the following folder:
~/Views/Test/Test.cshtml
You also need a controller named similarly in the following folder:
~/Controllers/TestController.cs
and inside that controller you need a method that matches the name of the view:
public ActionResult Test()
{
return View();
}
That will make http://[yourwebsiteurl]/Test/Test be an active page.

ASP.NET MVC application root changes on submit

I've got a simple ASP.NET MVC application for CSV file validation. The user enters some characteristics about the file (text box and some checkboxes), then browses to the file they want to upload and hits submit. The entire application works fine on my local machine and also on an internal web server, but does not work when placed in the external hosting environment. Below are the details.
Originally the file contents on my machine were copied out to the server. This means that bundling of the CSS and JS was not enabled. The application page would render just fine and the submit would also work. However, after submitting the file, the application root changes.
I've been checking the application root with the following code places inside the view.
var applicationpath = '#Url.Content("~/")';
The path is correctly output as something like the following when it's rendered for the first time.
var applicationpath = '/folder1/folder2/folder3/appfolder/';
After submitting the file, it changes to.
var applicationpath = '/folder1/folder2/folder3/';
I've checked with the hosting provider and they've got the application set up on "appfolder" and "folder3" is just a directory in IIS and not set up as an application.
The form in the MVC view is set up to post in the following way.
#using (Html.BeginForm("Upload", "Home", FormMethod.Post, new { enctype = "multipart/form-data", id = "wizard" }))
Since the path changes, this obviously messes up any #Url.Action,#Html.ActionLink, and other Razor methods that are supposed to automatically map to the root. The odd thing is that the CSS and JS files continue to be mapped in the rendered output.
After all of that, I decided to try to Publish the application through Visual Studio to a local file folder and then copy the results out to the hosting provider. This enabled bundling for the CSS and JS files. Now when I go to the root of the application, none of the CSS or JS is pulled down. I've tried grabbing the path to the bundled JS or CSS files and putting that in the browser, but I get a 404 error. The rendered output looks like this:
<link href="/folder1/folder2/folder3/appfolder/Content/css?v=J7SZFaeCsOxTbb847HlSpnWlcb1lMDolldSj5wq-hdc1" rel="stylesheet"/>
Needless to say, I'm at a loss. I've asked the hosting provider to tell me what IIS features they have installed and they have. See below.
IIS Features 1
IIS Features 2
The 3rd party was able to give me RDP access to the server. I turns out that they were using URL Rewrite in IIS and some of the rules were interfering with the MVC application. After they disabled the rules for the application folder, everything worked as it should.

The resource cannot be found

I created a new ASP.NET MVC 2 Empty Web Application. I didn't add any line of code to it. I simply ran the application by pressing F5 .The browser opens and I get an error message stating that
The resource cannot be found. Description: HTTP 404. The resource you
are looking for (or one of its dependencies) could have been removed,
had its name changed, or is temporarily unavailable. Please review
the following URL and make sure that it is spelled correctly.
What is the problem?
By default the empty project doesn't have any controller defined in it.
So first add it and then run it.
I have created MVC2 web application.
Account controller and Home controller is available by default and run the application is does not get any error.
And second time i have created MVC2 Empty web Application .
None of controller,views and model are present in this project.After this i simply run application and i got same error as you say.Yes this error will come because none of controller,view and model is not present.So first try to make MVC2 Web application
and second time try to make MVC2 Empty web application
and add one controller ,view and model
Steps are below:
1)First make on model name as City under Model Folder for example:City.cs
2)Then make one Folder under View folder name as City
3)Make one view under City folder name as Index
4)Make one controller under Controller folder name as CityController.cs
5)Bydefault Index method is present in citycontroller so no need to make it.
6)After this run the application with browser url is localhost://City/Index

How do I download an msi file via an asp.net button?

So, I've created my wonderful winforms app that I want to unleash upon the world, and now I am trying to create a simple website to host some basic information and link to the setup file (msi installer file )....
I have a button on the asp.net page and the setup file setupApp.msi in same folder as the asp.net page. I am currently trying the following:
Response.Redirect("http://./SetupApp.msi");
But this best guess at what to do is not working. Is there something wrong with Mime types here? What do I need to put in the click event to allow users to download this file?
The path you are passing in to the method is not valid (there's no server name called ".").
You can pass in a relative path and it should work fine because ASP.NET will resolve the path:
Response.Redirect("SetupApp.msi")
Or if it's not in the same folder, try one of these:
Response.Redirect("../Downloads/SetupApp.msi")
Response.Redirect("~/SomeFolder/SetupApp.msi")
Keep in mind that you don't necessarily have to do the whole redirect at all. Instead of writing code in an ASPX file you could just have a link to your MSI:
Download my app!

Resources