C
C#17mo ago
cptshape

✅ asp.net 6.0 + EntityFramework + IIS

I have a Web Api project, I set my ConnectionString on appsettings.json. In Program.cs I used the connection string to link with my DbContext. When I run the project on Visual Studio it works perfectly, when I publish it with IIS it doesn't work, it says "Page is not working". When I replace "return await _context.SalesData.ToListAsync();" with a handwritten data, page loads and shows the data so IIS works but EntityFramework doesn't work when published I believe. I couldn't find a solution anywhere, if anyone knows what I'm missing please help!
72 Replies
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
cptshape
cptshapeOP17mo ago
I ran with the .exe now it worked this way it shows the data
cptshape
cptshapeOP17mo ago
so IIS problem?
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
cptshape
cptshapeOP17mo ago
I published with this option before should I try doing the dotnet publish
cptshape
cptshapeOP17mo ago
When I publish like this I get a .exe
MODiX
MODiX17mo ago
TeBeCo
you also probably should use dotnet publish and not the publish from VS
Quoted by
React with ❌ to remove this embed.
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
cptshape
cptshapeOP17mo ago
It was inside a folder I created inside inetpub\wwwroot
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
cptshape
cptshapeOP17mo ago
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
cptshape
cptshapeOP17mo ago
yes unfortunately
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
cptshape
cptshapeOP17mo ago
just created a folder called iis and published it there, changed the path from IIS
cptshape
cptshapeOP17mo ago
still it says page is not working
cptshape
cptshapeOP17mo ago
this WeatherForecast controller was auto created when i create my web api project, it works but my controller doesn't so I'm not sure if problem is with IIS
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
cptshape
cptshapeOP17mo ago
okay hold on
cptshape
cptshapeOP17mo ago
It translates to "This page is not working" "localhost is currently unable to process this request." when I use PersonelController's url but the WeatherForecast works which automatically created with the project. When I replace my _context.SalesData.ToListAsync(); with just a simple string that I define myself page loads
cptshape
cptshapeOP17mo ago
and you mean this ?
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
cptshape
cptshapeOP17mo ago
cptshape
cptshapeOP17mo ago
sorry needed to refresh i guess its Opera GX
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
cptshape
cptshapeOP17mo ago
I removed the api/ part from here
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
cptshape
cptshapeOP17mo ago
yeah
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
cptshape
cptshapeOP17mo ago
cptshape
cptshapeOP17mo ago
I can try on Chrome
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
cptshape
cptshapeOP17mo ago
yeah I tried doing this on a different computer it was giving me the same error now I switched to my own computer did everything all over again and same error
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
cptshape
cptshapeOP17mo ago
chrome looks exactly the same as far as i can tell
cptshape
cptshapeOP17mo ago
okay I'll try doing try catch
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
cptshape
cptshapeOP17mo ago
it says that it can't be converted to "Personel" class type
cptshape
cptshapeOP17mo ago
and I can't leave it empty either what should i put there
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
cptshape
cptshapeOP17mo ago
aha no worries I'm worst I don't get to judge
cptshape
cptshapeOP17mo ago
still
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
cptshape
cptshapeOP17mo ago
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
cptshape
cptshapeOP17mo ago
alright haha
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
cptshape
cptshapeOP17mo ago
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
cptshape
cptshapeOP17mo ago
login failed
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
cptshape
cptshapeOP17mo ago
its not gonna be used anywhere it's been given to me to learn how to do entityframework and how to do webapi so it can be leaked np
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
cptshape
cptshapeOP17mo ago
nope
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
cptshape
cptshapeOP17mo ago
I got a good pc but I should stick with the sql express and IIS for this project I'm instructed to use these I could try to use docker etc when I'm done with this to learn more So I haven't understood this part much do I give the permission from SQL express or somewhere else
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
cptshape
cptshapeOP17mo ago
I see
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
cptshape
cptshapeOP17mo ago
I think I did it hold on
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
cptshape
cptshapeOP17mo ago
It worked!
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
cptshape
cptshapeOP17mo ago
since its not gonna be used anywhere i just gave every permission to it lol
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
cptshape
cptshapeOP17mo ago
yeah I'll try changing those to see which ones it need and do not give unnecesaryy ones etc. Thank you very much for your help man I tried doing this whole thing 3 times 😄
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
cptshape
cptshapeOP17mo ago
Just one more question idk if you know but the reason for this web api is to Create an another project (.net maui) so it works on windows/android/ios etc. The person who told me to learn this IIS thing said to make it work on android you need to have web api. So all i need to do now is connect to this URL from the .net maui and get the data from there, deserialize it and it should work ?
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
cptshape
cptshapeOP17mo ago
thats exactly what I was gonna use I was looking now lol okay I'll avoid that then I'll check out that document and maui tomorrow I'll accept this win for today haha thanks for everything again
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
cptshape
cptshapeOP17mo ago
/close
Want results from more Discord servers?
Add your server