GitLab: Project Not Found: Runs Fine Locally, Doesn't Work Deployed - c#

We have an app that updates a gitlab project and pushes/commits to master. When I run locally, the program runs fine. When I run on the application hosted server (not the gitlab server), I get a 404 "Project not found".
It's not the private access token, we just made a new one
I can sign in to gitlab on our app hosted server and find the project
I verified the account can push straight to master
There is no xdt transformation on the config files
I logged into the account on the app hosted server and hit the project via the same api url.
Here is the codified url:
RestRequest fileExists = new RestRequest(
$#"api/v4/projects/{project.id}/repository/files/{action.file_path.Replace("/", "%2F")}?ref=master&private_token={ConfigurationManager.AppSettings["JiraPrivateKey"]}",
Method.GET);
I'm almost thinking it's some sort of server setting, but I would think that I would get the 404 when I tried the api url in the browser.

After thinking about it, since I use the ConfigurationManager, I had to copy by .exe.config file to the server and not just the exe itself. After dragging the config and the exe over. It worked. :-(

Related

404 connection error when client redirects from server during MVC Project deployment to IIS

I have an app in React, that when we click on SUBMIT button the app redirect:
fetch(`https://ilqacitopsiis01/TicketMasterServer/validation?repoName=${repoName}&&branchName=${branchName}`)
The controller do some stuff and returns IActionResult(StatusCode of 500/502/200):
[HttpGet("validation")]
public IActionResult RequestBranchRepoNames(string repoName, string branchName)
When I'm running it locally in my computer with localhost it's running with no problems, but when I put it on IIS in order to deploy it just return 404, it mean that it's doesn't even ask from the controller the query. (like it doesn't know him).
Does anyone know what should I do so the react code will know the controller code also in IIS?
(I already added web.config to my C# repo)
I found the problem!
I should have run the command
dotnet publish
And not npm run build in the client, and just rebuild the C# project.
The publish folder created in the Debug->.net 5.0.

Response.Redirect() Works in Visual Studio but not IIS

I'm trying to upload a basic web application from visual studio on Windows 7 to an IIS environment on Windows Server 2007.
Though launching it from IIS displays the Login page, trying to navigate past it to the main menu returns this error:
Server Error in Application "PARKING/PARKING ASSIGNMENTS WEB"Internet Information Services 7.0
Error Summary
HTTP Error 404.0 - Not Found
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable. Detailed Error Information
Module IIS Web Core
Notification MapRequestHandler
Handler StaticFile
Error Code 0x80070002
Requested URL http://localhost:81/Parking Assignments Web/Home
Physical Path C:\ParkingAssignmentsWeb\Home
Logon Method Anonymous
Logon User Anonymous
Most likely causes:
•The directory or file specified does not exist on the Web server.
•The URL contains a typographical error.
•A custom filter or module, such as URLScan, restricts access to the file.
Things you can try:
•Create the content on the Web server.
•Review the browser URL.
•Create a tracing rule to track failed requests for this HTTP status code and see which module is calling SetStatus. For more information about creating a tracing rule for failed requests, click here.
Links and More InformationThis error means that the file or directory does not exist on the server. Create the file or directory and try the request again.
View more information »
This is the code I used for navigation:
Response.Redirect("Home.aspx");
Why would this navigation work on Visual Studio but not on IIS?
UPDATE: I tried the variations of the Redirect command you guys showed me but all of them gave a 404 error, which leads me to believe that the problem isn't with the command but with something else. Any idea what?
It treats Home.aspx as a relative path.
Use it like:
Response.Redirect("/Home.aspx");
when you deploy to IIS a different web server is being used. Visual studio uses a web server with limited options and in most cases but not all an application should run without changes when deployed to IIS on windows server.
Things to check
Verify that the folder structure on your workstation looks the same as the folder structure deployed to the server.
check permissions on the folders accessed by IIS on the web server
Response.Redirect("Home.aspx"); assumes that the file is in the same directory as the page that is invoking the transfer
add a more complete path either ("/home.aspx") or ("/folder/home.aspx") where folder is the actual folder name that contains the .aspx file
Please try:
Response.Redirect("~/Parking Assignments Web/Home.aspx");
or
Response.Redirect("~/Parking Assignments Web/Home");

IIS Hosted Project on Virtual Machine not resolving localhost for Scripts

I have a Published ASP .NET MVC web project running in IIS within a VMWare Virtual Machine(Windows 7). I am able to log in to the VM and navigate across the application from within the VM itself, but all content files(JS, CSS) are returning a 404 error.
i.e : 'http://localhost/WebProject/Home/Index' loads fine, but, 'http://localhost/WebProject/Scripts/Home/IndexScript.js' within that page throws a 404 error.
Any ideas?
If you can access IIS on your VMWare it means that your IIS works fine and VMWare too but there some settings which restrict access to some urls or url is wrong.
Are you sure that you have file at path /Scripts/Home/IndexScript.js'
If yes then check
IIS not serving static content (css/js/images, etc) 404
IIS7 returns 404 on some static files, not others

Losing Credentials when Invoking Command with WinRM

I have written a Console application that makes an HTTP POST to a ASMX Web Service (within Sharepoint) that I am looking to invoke remotely with WinRM. I have written a PowerShell process that bundles up the built application, moves it to the destination server, and executes it locally. The process works completely fine (ie moving copying, what-have-you), but fails when it gets to the Web Service call. Looking at logs on Fiddler, the HTTP Post request has no credentials in it at all, even though the application is being ran with an account that has all the proper permissions.
Since the application is moved to the destination server locally, I can run it locally, which I have done, and it works completely fine, as the Fiddler logs show the correct credentials in the header.
I am not sure where the issue resides, but I am having a hard time thinking its my code, since it works fine when ran locally. It may be with the WinRM process, but the exact same process works for other environments (this project is part of a larger deployment solution that deploys databases, ssis packages , etc).
I am happy to provide code of certain pieces if needed, and any basic troubleshooting advice would be greatly appreciated.
EDIT
The user credentials I specify in a xml file that contains the username and a hashed password, like this in Powershell
powershell.exe -version 3.0 -ExecutionPolicy RemoteSigned -command "& { $cred=Import-Clixml '%CREDENTIAL_FILENAME%' ; $cred.Password=ConvertTo-SecureString $cred.Password ; $Credential=New-Object System.Management.Automation.PsCredential($cred.UserName, $cred.Password) ; invoke-command -computername %MACHINE% -filepath %Result% -Credential $Credential }"

CreateDirectory in a web service fails on remote server

System.IO.CreateDirectory or System.IO.File.Create won't work from a web service when navigating to the app remotely. It works locally.
Environment:
- .Net 4.5, Asp.Net, C#
- VS 2012
Remote:
- Windows 08 R2
- IIS 7
- App Pool (.Net 4.0, Integrated)
Process:
The web service is in the project and is used in jQuery .ajax call with url: 'Services.asmx/UploadFile'. The WS method creates the folder chain (if not found) and writes the file.
The file upload works perfectly fine locally in VS.
It also works perfectly when published on a remote server and navigating to it locally on the server (thru RDC) either by localhost/{app} or by http://{ip}/{app}. The folder chain is created and file is written.
However, it does not work when navigating to it normally.
I'm pretty sure it's a user permission issue but I've exhausted all options. I've assigned modify rights on the app folder in wwwroot to "NETWORK SERVICE" and even though I'm sure unnecessarily to "IIS_IUSRS", "IUSR", "LOCAL SERVICE", "NETWORK" and none have helped! I just keep getting status 500 when I navigate to it normally. But it has always worked locally as mentioned above once I gave it "NETWORK SERVICE" modify rights.
Publishing a basic test app with a button and CreateDirectory in code-behind on the same server worked after assigning modify rights to "NETWORK SERVICE" on the app folder in wwwroot.
The create directory code in the web service is:
[WebMethod]
public void UploadFile()
{
string _userId = HttpContext.Current.Request.Form["userId"];
HttpPostedFile _file = HttpContext.Current.Request.Files["Filedata"];
string _uploadsFolder = Server.MapPath(String.Format(ConfigurationManager.AppSettings["FileUploadPath"], _userId, "Temp"));
if (!Directory.Exists(_uploadsFolder)) Directory.CreateDirectory(_uploadsFolder);
FileStream _fileStream = File.Create(Path.Combine(_uploadsFolder, _file.FileName));
_file.InputStream.CopyTo(_fileStream);
_fileStream.Close();
}
FileUploadPath in web.config is
When it works, it works with or without the "~/" in the path. And when it doesn't work, it's the same, with or without, it won't work.

Categories

Resources