How to keep Global.asax from being compiled into the app - asp.net-mvc-3

Working with a MVC3/.NET Framework4/IIS7.5 app that in previous deployments has included the Gobal.asax.cs copied to the server. Some setting or configuration has changed that behavior now to include just the Global.asax with none of the codebehind included. The properties setting shows Copy Always | BuildAction Content which is, I think, what it should be.
I'm deploying via FileSystem (a vpn connection to my remote host) because I presume that to be the fewest deployment hoops - I know from my point of view it's preferable to the alternate deployment methods.
Is that having an effect on how Global.asax is being treated - where else should I be looking?
thx

Using Visual Studio 2012 I was able to produce a published build on my local file system which included Global.asax.cs by setting the Build Action and Copy to Output Directory properties of the Global.asax.cs file to:
Build Action : Content
Copy to Output Directory : Copy always
I suspect you've only set these property values on the Global.asax file.
This was performed on an ASP.NET MVC3 C# project.

Related

Setting ServiceHost in VisualStudio when Working with Docker

If you create a ASP.NET Core 3 Web API service it makes a file called launchSettings.json under "Properties". That file has the following setting under docker:
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/index.html",
I am trying to find a way to set the ServiceHost part of this. (Apparently this defaults to localhost.) I tried adding
<ServiceHost>mycomputer.mydomain.net</ServiceHost>
to a PropertyGroup in my csproj file, but it had no effect (the default page loaded was still localhost). (Though it will still work when I enter mycomputer.mydomain.net.
How can I set ServiceHost for my docker run?
NOTE: I would love an answer that includes how to do this with docker-compose as well. (I tired moving this to docker-compose and only localhost would work (mycomputer.mydomain.net stopped working).

Typescript 1.0 map files do not load

In VS2013 update 2 RC (Typescript 1.0 RTM) I cannot debug TypeScript files in one of my projects. I have traced this back to the map file declaration. By default my JS file contains:
//# sourceMappingURL=general.js.map
Which should be correct, the map file is in the same folder as the TS and JS files. However it doesn't work. if I manually edit the file, specifying the full path, it works:
//# sourceMappingURL=C:/Users/myname/Documents/Visual Studio 2013/Projects/Test/JSLib/general.js.map
This confuses me, because surely the browser shouldn't understand the full path, eg outside the IISExpress web site?
Can anyone suggest a way to get map files working with the first mapping? Thanks
Windows 8.1 x64, IE11
Update: the app, running through IISExpress, uses Windows authentication. if I turn this off the map files load! Also, checking the output window I see:
SourceMap http://localhost:53524/JSLib/general.js.map read failed: The remote server returned an error: (401) Unauthorized.'iexplore.exe' (Script): Loaded 'http://localhost:53524/JSLib/'.
My IIS Express logs contain
2014-04-12 13:58:24 ::1 GET /JSLib/general.js.map - 53524 - ::1 - - 401 2 5 0
But I can browse to http://localhost:53524/JSLib/general.js.map fine in IE. So what's making the call for the map file (VS?) and how to I get it to use my credentials?
I too have been experiencing this problem. I am sorry to say that I do not know what the root of the problem is. However, I have found a workaround.
Open your project properties and go to the 'TypeScript Build' tab. In the 'Debugging' section, check the 'Specify root directory of the source maps' option and enter the value $(ProjectDir)\Scripts.
This works with Windows Authentication enabled and with the default 'sourceMappingUrl'.

How to Deploy ASP.NET web application using InstallAware

I have a ASP.NET web application.
Now I want to create a installer using InstallAware so that my customers just click on the installer and it will be put on the web server as well as configure IIS for the web application
Is there any one who can instruct me how to do it? This is the first time I am using InstallAware
Thanks in advance,
Mohin
If you have access to InstallAware's MSICode, you can use the following code:
In the Define Setup Globals Section:
Get Folder Location WWW->WWWRoot into WWWROOTDIR
In the Perform First Time Install section, just before calling Apply Install:
Install Files D:\Projects\mywebsite\Release\*.* to $WWWROOTDIR$\mywebsite, include subfolders
In your Perform First Time Install section, after Apply Install is done:
if Variable SUCCESS not Equals ERROR
if Variable SUCCESS not Equals CANCEL
Get IIS Index for Site "Default Web Site" into DEFAULTWEBSITEINDEXVAR
Create Virtual Folder "mywebsite" in IIS Site #$DEFAULTWEBSITEINDEXVAR$, pointing to physical location $WWWROOTDIR$\mywebsite
Get System Setting IIS Anonymous User Account into INETUSR
Set Read Permissions on File System Object "$WWWROOTDIR$\mywebsite" for Current User Authenticated Users $INETUSR$
end
end
If you do not have access to MSICode, this is still easy to do using the InstallAware Designer.
Go to Server Configuration > IIS Sites
Create a Virtual Directory under "Default Web Site"
Make sure you choose the correct ASP.NET version, and that Default.aspx is on top of the Documents tab file listing.
Enable appropriate Directory Security settings
The rest of the settings can stay default
Go to Setup Architecture > Files
In the directory list below, if $WWWROOTDIR does not exist, create it by Right-clicking on "Target Folders" and choosing "Add System Folder", "WWW->WWWRootDir"
Create a sub-folder under that with the name of your virtual directory
Add all files you need for your ASP.NET application here - you can use wildcards too
This should be enough to have InstallAware setup the IIS website and your application.
If you have common Assemblies, you can directly install them into the GAC by adding them in the Setup Architecture > Assemblies page. The additional advantage is that you can choose to have ngen run on them.

Debugging Silverlight project with Visual Studio loads file not local webserver?

I've got a Silverlight project in VS 2010 that when I go to debug, my browser is spawned, but the file:// location is attempted, rather than loading the http://localhost location.
How can this be fixed?
Thanks.
-- Update --
The specific error is as follows:
The provided URI scheme 'file' is
invalid; expected 'http'. Parameter
name: via
The error makes sense, but the reason why it's trying to load up file: rather than spawn the local server is the issue.
First, you'll need to have a web project to host the silverlight app.
Second, edit your web application properties (select the project then press ALT + Enter) and add a reference to your silverlight application in the "Silverlight" tab. Now whenever you build your applications, a copy of the silverlight app will be copied to the web application.
After that, create a test page with some HTML and add an object tag with the url to the silverlight xap file.
Also, make sure your web application is set as the default startup application.

"Run Custom Tool" for resx files in MVC2 project (from an external application/script)

I am trying to get the localization for my MVC project working with our existing infrastructure for editing string resources. We store all our resource string in database tables and have a front end web UI to edit them with, and an export application which generated the .resx files. This all works great, but I am having a little difficulty with a new project using MVC2 and VS2010.
I have asked another question on this, the answer to which almost got me there, but not quite.
I have now changed the resources to be in a Resources folder (instead of App_GlobalResources), as recommended by a number of people. And have the following settings against my .resx files ...
Build Action = Embedded Resource
Copy to Output Directory = Do not copy
Custom Tool = PublicResXFileCodeGenerator
Custom Tool Namespace = Resources
File Name = MyApp.resx
I have changed my export application to run the resgen.exe tool with the following parameters ...
string args = string.Format("/publicClass \"{0}\" /str:cs,Resources,{1},\"{2}\"", resourceFile, Path.GetFileNameWithoutExtension(resourceFile), csFilename);
... which generates an almost identical .designer.cs file as I get when I add the .resx file to my project initially. The only difference is the
The generated .designer.cs file differs slightly from the file I get when I run the resgen.exe tool from within my export application.
This is the code generated by VS2010 when I first add the .resx file to my Resources folder ...
public static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Resources.MyApp", typeof(MyApp).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
... the difference when I run the resgen.exe tool is that is prefixs MyCompany.MyApp to the namespace in the constructor to ResourceManager
new global::System.Resources.ResourceManager("MyCompany.MyApp.Resources.MyApp", typeof(MyApp).Assembly);
Now, this to me seems to be a bug in the resgen.exe tool, because I've told it that the Namespace for my resources is Resources, not MyCompany.MyApp.Resources.
So, is there a fix/work-around for this problem?
The only thing I can think to do at the moment is to post-process the generated .designer.cs file with powershell and fix it!
Finally, I have solved the problem.
I decided to simplify things a bit by breaking my resources out in to a new assembly called Resources. I then added my resx files and set the properties for them as below ...
Build Action = Embedded Resource
Copy to Output Directory = Do not copy
Custom Tool = PublicResXFileCodeGenerator
Custom Tool Namespace = Resources
File Name = MyApp.resx
I then changed my export application to run ...
resgen MyApp.resx /str:c#,Resources,MyApp,MyApp.designer.cs /publicClass
... and to delete *.resources from the folder (created by the resgen.exe utility, but not needed)
This got rid of the prefix on the constructor to ResourceManager, and then i just added a reference to my new Resources assembly to my web application.
I've run a few tests to make sure all is good, including going in to the .designer.cs file and deleting one of the properties to cause a compiler error. Then re-ran my export app, and everything worked again.
So, I am a happy bunny!

Resources